Sending Email Attachment using VF Email Template

By | July 20, 2017

Salesforce provides different types of Email templates like Text template, HTML, Custom and Visualforce email template. The visualforce email template is a very powerful template type as we can create a custom Visualforce page and display it as an Email body. Along with this, it also provides flexibility of adding an attachment in the mail.

Please find below code snippet to demonstrate the same:

code snippet demonstrating adding attachment in the mail

code snippet demonstrating adding attachment in the mail

Visualforce template allows us to add an attachment of different types such as pdf, excel, csv or html file. The type of an attachment is specified using “renderAs” attribute. You can also specify the name of the file using “filename” attribute.

The result of the above code snippet looks like:

Email along with attachment

Email along with attachment

After opening up an attachment, it looks like:

PDF attachment

PDF attachment

Thus, we can send any file or document as an attachment along with mail using Visualforce email template.

Also Read
1. Creating Global Picklist Value Set in Salesforce
2. Using Nested Lightning Components in Salesforce
3. Expand and Collapse panel using Lightning Component
4. Creating a VisualForce Page with the help of Lightning Design System
5. Avoiding API Limits in Test Classes

About Us
Greytrix is one stop solution provider for Sage ERP and Sage CRM needs. We provide complete end-to-end assistance for your technical consultations, product customization’s, data migration, system integrations, third party add-on development and implementation expertise.

Greytrix have some unique solutions for Cloud CRM such as Salesforce integration with Sage X3, Sage 100 and Sage 300. We also offer best-in-class Cloud CRM Salesforce customization and development services to business partners and end users. Greytrix have some unique solutions for On-Premise CRM such as Sage CRM integration with Sage X3, Sage 100, Sage 300, Sage 500 and Sage 50 . We also offer best-in-class On-Premise Sage CRM customization and development services to business partners and end users.

For more information, please contact us at salesforce@greytrix.com. We will be glad to assist you.