-
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
6 Tactics to Measure Performance of Your Remote Salesforce Engineers
Reluctant to hire remote Salesforce engineers? Because you can’t get that nagging feeling out of your mind — “are your remote Salesforce developers being productive or…
Learn About Salesforce Deployment Using Change Set
Salesforce Deployment Using Change Set To handle alter set arrangement from sandbox to generation, take after the informational recorded below. By utilizing alter sets we…
What is Salesforce Digital Engagement in 2024?
What is Digital Engagement? Salesforce Digital Engagement is a customer service product that helps companies communicate with customers via messaging apps, webchats, in-app chats, and…
Popular Salesforce Videos
Salesforce App Builder Training | Salesforce App Builder Tutorial | Intellipaat
In this salesforce app builder tutorial, you will learn what is Salesforce CRM, a Sales rep in Salesforce, various user settings in Salesforce, and how…
Migrating from Salesforce NPSP to Nonprofit Cloud
The Salesforce Nonprofit Success Pack (NPSP) is a longstanding managed package with a user-friendly constituent management application and fundraising tool. However, Salesforce is pivoting nonprofit…
Accelerate Revenue by Simplifying Partner Data Exchange
Adeptia Webinar :: Self-service approach to set up secured B2B data exchanges. Allowing IT to focus on governance for ensuring compliance, security, and control.Reducing IT…