-
I am new to salesforce. i want to send email with attachment
I am new to salesforce. i want to send email with attachment that stored in static resources. please tell me how to do it
Answer-
public class EmailStaticResource {
public void StaticresourceDataAsEmail(){
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
email.setUseSignature(false);
email.setSaveAsActivity(true);
email.setSubject('Send Email using staticResource as body of mail ');
String[] toAddresses = new String[] {'ganesh.maharana@janbask.com'};
email.setToAddresses(toAddresses);
email.setHtmlBody('<html><body>Dear devoplers<b>See the code for Email service</b></body></html>');
StaticResourcesr = [Select Name, Id, Body From StaticResource where Name = 'Document'];
Blob tempBlob = sr.Body;
Messaging.EmailFileAttachmentefa = new Messaging.EmailFileAttachment();
efa.setBody(tempBlob);
efa.setFileName('attachment.pdf');
email.setFileAttachments(new Messaging.EmailFileAttachment[] {efa});
Messaging.SingleEmailMessage[] emailList = new Messaging.SingleEmailMessage[] {email};
Messaging.sendEmail(emailList);
}
}
Log In to reply.
Popular Salesforce Blogs
How to Reach Better User Experience of a Salesforce App with a Webix-based Data Grid
Each growing business should continuously evolve since customers are becoming more demanding every day. As a result, software solutions are becoming obsolete very fast. The…
Top 7 Business Problems Solved Through Salesforce Customization Services
Modern enterprises often treat Customer Relationship Management (CRM) platforms as out-of-the-box solutions, only to discover that generic structures fail to support proprietary operational workflows. Gartner…
Understanding Web Server Authentication Flow | Web App Integration
Integration Using Web Server Flow Allows apps with a secure client-server (private key or anything that can protect the private key) to access protected resources.…
Popular Salesforce Videos
Integration using Salesforce Connect
Salesforce Connect is a powerful App Cloud integration service, which enables users of Salesforce applications to seamlessly access and handle data stored in external sources,…
Salesforce Winter 18 Release for Busy Admins
Contents: Lightning Report Builder Dashboard Report Filter Lightning Hover Components Conditional Page Components Setup Search in Lightning Lead Conversion Updates User Interface Settings
COVID-19 Impact on The Automotive Industry -Digitization With Salesforce Can be a Solution
Coronavirus is expected to create a physical contactless environment with an increased thrust on online assessment and buying of vehicles. This is a huge shift…