-
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
Salesforce Administrator Responsibilities - What Needs to be Done and When
In this Top Salesforce Blog, we will be discussing Salesforce Administrator Responsibilities and what it is, what the profile talks about, what are the requirements,…
Flow Builder and Approval Process in Salesforce
Flow Builder is the interface where Flows can be designed and tested. The below screenshot shows the Flow builder screen, and the following table explains…
Popular Salesforce Videos
Introduction to Salesforce CPQ | EP1
Session 1: Introduction to Salesforce CPQ: The video provides an introduction to the general quoting challenge many Customers face, and how Salesforce CPQ with its…
What is Salesforce? Career Opportunities and Job Roles in Salesforce!
This video deals with the most important aspect of Salesforce. You'll learn the following things from this video:- 1. What is Salesforce? 2. What business…
Tableau CRM for Emergency Response Management | Salesforce
When disaster strikes, public and private health organizations, as well as government agencies, need to respond quickly and efficiently. Tableau CRM for Emergency Response Management…