-
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
5 Ways to Measure Customer Feedback | Salesforce Guide
As obvious as it sounds, you can only sell a product that your customers want to buy. So collecting customer feedback is crucial to measure…
Case Study: Salesforce Pharma Order Management System Transformation
Key steps are taken to optimize operational efficiency and Salesforce integration in the pharmaceutical industry. Managing orders across diverse markets presents challenges that demand innovative…
Salesforce REST API
This post will describe the Salesforce Rest API and how to get the usage from the Salesforce Rest API using a connected app. Don’t forget…
Popular Salesforce Videos
Data Cleansing in Salesforce and Salsa - Why it matters?
Research by Blackbaud found that 67% of data available to some nonprofits were un-mailable. That is either a lost opportunity or wasted money. This especially…
How to Build an Offline Salesforce App, Part 1: Authenticate with Salesforce
This video tutorial will guide you through the following steps: * Integrating the Salesforce connector * Modifying the login screen and process * Authenticating with…
Pardot Engagement Studio | Salesforce
Learn how to use Pardot Engagement Studio to engage and attract prospective students. Do let us know in the comment section if you have any…