Send emails with attachments from salesforce using sendgrid

About Sendgrid:
SendGrid is the world’s largest Email Infrastructure as a Service provider and it as easy as possible to add reliable, scalable email to your application.

SendGrid has been built from the ground up as an API company. make it easy to send email no matter your environment. You can send email over SMTP or HTTP, and even use from sendgrid client libraries.

see more details:

About Salesforce:
Salesforce is a leading enterprise customer relationship manager (CRM) application.

Using sendgrid you can send the emails to salesforce leads, contacts, etc

This Apex Toolkit (sendgrid-apex) allows you to quickly and easily send emails through SendGrid using Salesforce Apex.

To install SendGrid Apex Toolkit in your Salesforce Org please use the below link:

You can rewrite your code as per your business requirement:

Blob att = pdf.getContentAsPDF();
public static void send(String emailRecipient, String emailSubject, String emailBody, Blob att){

  SendGrid sendgrid = new SendGrid(‘username’, ‘password’); email = new SendGrid.Email();
email.addAttachmentStream(“attachment.pdf”, att);

String response = sendgrid.send(email);

Written by 

2x Salesforce MVP | Platform Champion | 18x Salesforce Certified | MuleSoft Certified | 8x Trailhead Ranger | TechForce Services | Sydney | Australia

Leave a Reply

Your email address will not be published. Required fields are marked *