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

Send email with attachments

Hi All,


My organization has a custom oject, proposals. Each proposal has multiple pdf files attached to it, which are listed in the notes and attachments related list. Whenever a salesforce user clicks on 'send email' button from the activity history, these attachments should automatically be attached in the send email visualforce page. The user should have an option to check or uncheck any of the attachments, i.e. he can send only the attachments that he would choose. Is there a way to achieve this using visualforce templates or should I create a custom visual force page for this and have the send email option as a custom button? I should retain the rich features of the standard email page of the salesforce. In either case, can you please help me with some example code on how this can be achieved. 




Praful GadgePraful Gadge

There is no standard way to achieve this. However, you can create a custom page and controller to get this done. In controller you can write below code


Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); mail.setToAddresses(toAddresses);   // set the to address
mail.setCcAddresses(ccAddresses);   //set the cc address
mail.setSubject('Give the subject......');
mail.setPlainTextBody('Give the email body');
mail.setWhatId(case.Id);// Set email file attachmentsList<Messaging.Emailfileattachment> fileAttachments = new List<Messaging.Emailfileattachment>();
for (Attachment a : [select Name, Body, BodyLength from Attachment where ParentId = :proposal.Id]){  // Add to attachment file list  Messaging.Emailfileattachment efa = new Messaging.Emailfileattachment();  
mail.setFileAttachments(fileAttachments);// Send emailMessaging.sendEmail(new Messaging.SingleEmailMessage[] { mail })
jaya sai prasadjaya sai prasad

If you want to send an Email with Attachment a native salesforce app MassMailer DOCS is perfect for you.

MassMailer DOCS let’s you send mass email attachments to your leads or contacts while securely storing your files with Rackspace Cloud Files.

You can try this app by installing from appexchange  -Massmailer Docs

You can learn more details about the product on this website -