function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
csteddy1csteddy1 

inbound email service apex class does not see all attachments

The oft copied code below  (which is hopefully correct), successfully processes binary attachments apart from some emails forwarded (with attachments) from gmail. (An email snapshot confirms that the inbound email has attachments). Has anybody had a similar problem? Is there anything obviously wrong with the code below?

 


    
    if (email.binaryAttachments != null && email.binaryAttachments.size() > 0) {
      for (integer i = 0 ; i < email.binaryAttachments.size() ; i++) {
        Attachment attachment = new Attachment();
        // attach to the newly created email record
        attachment.ParentId = e.Id;
        attachment.Name = email.binaryAttachments[i].filename;
        attachment.Body = email.binaryAttachments[i].body;
        insert attachment;
      }
    }

 

Thanks,

 

Craig

sfdcfoxsfdcfox
Are you sending the same files each time? Don't forget about Email.TextAttachments, which includes any mime type of 'text/*' or some binaries (vcf and vcs).
csteddy1csteddy1
Thanks for the reply. To reproduce the problem I forward the same email
with the 2 JPG attachments.
The email snapshot shows them. e.g.
Content-Type: 'image/JPEG'; name="1307262206280001.jpg"
Content-Disposition: attachment; filename="1307262206280001.jpg"
Content-Transfer-Encoding: base64
X-Attachment-Id: cc1846a3c009b87f_0.1

I accept all attachments and process text attachments as well (using almost
identical code).
If I compose a new email and send it with the same two attachments my apex
code sees the attachments???