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
kabkab 

Email attachment converting to html without any content

I am using Apex page Controller methods  to read the attachments and send using email attachments. When I reach above 3MB it is converting html file. Is there any issue or limitation on email attachments?

Suppose my file name is testfile.pdf then it converts to testfile.pdf.html.

if the file size less than 3mb it sends testfile.pdf

Document says it supports 10MB. if the size is morethann 10mb then I get error message Limit exceeded.

My code looks like below:

Messaging.Singleemailmessage    single_mail = new Messaging.Singleemailmessage();              
              

Messaging.EmailFileAttachment[] fileAttachments = new Messaging.EmailFileAttachment[ShowFiles.size()];
                for(integer cnt=0;cnt< fileAttachments.size(); cnt++)
                {
                  
                    Messaging.EmailFileAttachment fileAttachment = new Messaging.EmailFileAttachment();
                    fileAttachment.setBody(emailBodyBlob);
                    fileAttachment.setFileName(FileName);
                    fileAttachments[cnt] = fileAttachment;
                   
                } 
                single_mail.setFileAttachments(fileAttachments);
             }
           
            // Specify the text content of the email.
            single_mail.setPlainTextBody(body);
                       
            // Send the email you have created.
            Messaging.SendEmailResult[] result = Messaging.sendEmail(new Messaging.SingleEmailMessage[] { single_mail });
           
How can I send actual files upto10mb without converting to html.

Best Answer chosen by Admin (Salesforce Developers) 
sfdcfoxsfdcfox

This is due to the way salesforce sends attachments. To conserve bandwidth (and avoid compatibility issues with some mail services), attachments over 3MB are sent as links. The HTML file links to a CMS hosted by salesforce; opening the attachment will result in the file being downloaded. The CMS stores these attachments for 30 days, then discards the file. This is true any time an email is sent with attachments. You can verify this behavior by creating a contact record with your email address on it, and sending yourself a 5MB attachment as an example.

All Answers

sfdcfoxsfdcfox

This is due to the way salesforce sends attachments. To conserve bandwidth (and avoid compatibility issues with some mail services), attachments over 3MB are sent as links. The HTML file links to a CMS hosted by salesforce; opening the attachment will result in the file being downloaded. The CMS stores these attachments for 30 days, then discards the file. This is true any time an email is sent with attachments. You can verify this behavior by creating a contact record with your email address on it, and sending yourself a 5MB attachment as an example.

This was selected as the best answer
kabkab

Thanss for letting us  know. So is there any way we can send the actual file to the email and that will never be deleted?

sfdcfoxsfdcfox

The email must not be sent through the Force.com servers; all emails sent from clients through their servers are subject to this rule. Instead, consider using a third-party mailing system; most of them can integrate with Outbound Notifications or other means.