-
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 can Organizations Benefit From Salesforce Sales Cloud Implementation
Businesses today, irrespective of their scope or size need a feasible platform to pull through the fierce marketplace competition, nurture the existing customers, and acquire…
Salesforce Trigger Example to count number of completed tasks in a single contact
Below is an example of how to use Salesforce Trigger to count number of completed tasks in a single contact trigger UpdateAccountNameFromContactLastName2 on Contact (before…
Salesforce Awesome Admin Tips for Productivity | Salesforce Admin
It’s no secret that Salesforce continually ranks as one of the highest recommended cloud-based software management platforms. It has proven to be an incredibly robust…
Popular Salesforce Videos
4 Key Highlights From the Dreamforce Keynote Event
Let's straightaway take a jump on the announcements – from Hyperforce, Einstein Automate, Service Cloud Workforce, and huge acquisitions – presenting you a summary of…
Understanding Basics of CRM, Cloud Computing & Salesforce
With cloud computing, businesses access applications via the internet. It's called Software As A Service (or SaaS). Businesses are freed up from having to maintain…
Pardot Segmentation Lists | Pardot Tutorial | Salesforce Lightning Tutorial
Pardot Segmentation Lists. This video will cover the following points - 1. Types of Segmentation Lists (0:16) Take a look at the different types of…