+ Start a Discussion

Sending Documents (Notes & Attachments) via Email



Is there a way to send attachments associated with accounts and/or opportunities to someone who doesn’t have a Salesforce license via a system-generated email? The issue is that we customized and implemented Salesforce solution mainly for Sales staff. When a deal is done, we then need to somehow send some basic account/opportunity information and related documents (resided in Salesforce under an Opportunity) to an Account Executive. Currently, we are able to send an auto-generated email out to an Account Executive with account and opportunity information as part of the body of the email. Is there a way for us to be able to also send Salesforce attachments (associated with Opportunities) or links to those documents in the same email? This would allow our staff to be a lot more efficient as we are currently manually downloading documents from Salesforce and sending them to Account Executives. Thank you for your time.



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 = :case.Id]){  // Add to attachment file list  Messaging.Emailfileattachment efa = new Messaging.Emailfileattachment();  
mail.setFileAttachments(fileAttachments);// Send emailMessaging.sendEmail(new Messaging.SingleEmailMessage[] { mail })


 You can make use of the above code to send email to members outside salesforce.


Let me know, whether this will work for you.





jaya sai prasadjaya sai prasad
Hi prs8778,

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 - docs.massmailer.io