{"id":2583,"date":"2017-07-20T04:36:25","date_gmt":"2017-07-20T04:36:25","guid":{"rendered":"http:\/\/www.greytrix.com\/blogs\/salesforce\/?p=2583"},"modified":"2025-05-09T07:00:53","modified_gmt":"2025-05-09T07:00:53","slug":"sending-email-attachment-using-vf-email-template","status":"publish","type":"post","link":"https:\/\/www.greytrix.com\/blogs\/salesforce\/2017\/07\/20\/sending-email-attachment-using-vf-email-template\/","title":{"rendered":"Sending Email Attachment using VF Email Template"},"content":{"rendered":"<p><a href=\"https:\/\/www.greytrix.com\/product\/crm-development\/salesforce-com\" target=\"_blank\" rel=\"noopener noreferrer\">Salesforce<\/a> 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.<\/p>\n<p>Please find below code snippet to demonstrate the same:<\/p>\n<div id=\"attachment_2649\" style=\"width: 605px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/07\/Image1-code-snippet-demonstrating-adding-attachment-in-the-mail.jpg\" target=\"_blank\" rel=\"noopener noreferrer\"><img fetchpriority=\"high\" decoding=\"async\" aria-describedby=\"caption-attachment-2649\" class=\"wp-image-2649 size-large\" title=\"code snippet demonstrating adding attachment in the mail\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/07\/Image1-code-snippet-demonstrating-adding-attachment-in-the-mail-1024x360.jpg\" alt=\"code snippet demonstrating adding attachment in the mail\" width=\"595\" height=\"209\" \/><\/a><p id=\"caption-attachment-2649\" class=\"wp-caption-text\">code snippet demonstrating adding attachment in the mail<\/p><\/div>\n<p>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 <strong>&#8220;renderAs&#8221;<\/strong> attribute. You can also specify the name of the file using <strong>&#8220;filename&#8221;<\/strong> attribute.<\/p>\n<p>The result of the above code snippet looks like:<\/p>\n<div id=\"attachment_2650\" style=\"width: 709px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/07\/Image2-Email-along-with-attachment.jpg\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" aria-describedby=\"caption-attachment-2650\" class=\"wp-image-2650 size-full\" title=\"Email along with attachment\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/07\/Image2-Email-along-with-attachment.jpg\" alt=\"Email along with attachment\" width=\"699\" height=\"313\" \/><\/a><p id=\"caption-attachment-2650\" class=\"wp-caption-text\">Email along with attachment<\/p><\/div>\n<p>After opening up an attachment, it looks like:<\/p>\n<div id=\"attachment_2648\" style=\"width: 605px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/07\/Image3-PDF-attachment.jpg\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" aria-describedby=\"caption-attachment-2648\" class=\"wp-image-2648 size-large\" title=\"PDF attachment\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/07\/Image3-PDF-attachment-1024x505.jpg\" alt=\"PDF attachment\" width=\"595\" height=\"293\" \/><\/a><p id=\"caption-attachment-2648\" class=\"wp-caption-text\">PDF attachment<\/p><\/div>\n<p>Thus, we can send any file or document as an attachment along with mail using Visualforce email template.<\/p>\n<p><strong>About Us<\/strong><br \/>\n<a href=\"http:\/\/www.greytrix.com\/\" target=\"_blank\" rel=\"noopener noreferrer\">Greytrix<\/a> 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\u2019s, data migration, system integrations, third party add-on development and implementation expertise.<\/p>\n<p><a href=\"https:\/\/www.greytrix.com\/\" target=\"_blank\" rel=\"noopener noreferrer\">Greytrix<\/a> have some unique solutions for Cloud CRM such as Salesforce integration with <a href=\"https:\/\/www.greytrix.com\/product\/sage-x3\/gumu-x3-salesforce-integration\" target=\"_blank\" rel=\"noopener noreferrer\">Sage X3<\/a>, <a href=\"https:\/\/www.greytrix.com\/product\/sage-100-erp\/gumu-100-salesforce-integration\" target=\"_blank\" rel=\"noopener noreferrer\">Sage 100<\/a> and <a href=\"https:\/\/www.greytrix.com\/product\/sage-300-erp\/gumu-300-salesforce-integration\" target=\"_blank\" rel=\"noopener noreferrer\">Sage 300<\/a>. We also offer best-in-class Cloud CRM <a href=\"http:\/\/www.greytrix.com\/product\/crm-development\/salesforce-com\" target=\"_blank\" rel=\"noopener noreferrer\">Salesforce customization and development services<\/a> to business partners and end users. <a href=\"https:\/\/www.greytrix.com\/\" target=\"_blank\" rel=\"noopener noreferrer\">Greytrix<\/a> have some unique solutions for On-Premise CRM such as Sage CRM integration with <a href=\"https:\/\/www.greytrix.com\/product\/sage-crm\/gumu-sage-x3-integration\" target=\"_blank\" rel=\"noopener noreferrer\">Sage X3<\/a>, <a href=\"https:\/\/www.greytrix.com\/product\/sage-crm\/gumu-sage-100-erp-integration\" target=\"_blank\" rel=\"noopener noreferrer\">Sage 100<\/a>, <a href=\"https:\/\/www.greytrix.com\/product\/sage-crm\/gumu-sage-300-erp-integration\" target=\"_blank\" rel=\"noopener noreferrer\">Sage 300<\/a>, <a href=\"https:\/\/www.greytrix.com\/product\/sage-crm\/gumu-sage-500-erp-integration\" target=\"_blank\" rel=\"noopener noreferrer\">Sage 500<\/a> and Sage 50 . We also offer best-in-class On-Premise <a href=\"https:\/\/www.greytrix.com\/product\/crm-development\/sage-crm\" target=\"_blank\" rel=\"noopener noreferrer\">Sage CRM customization and development services<\/a> to business partners and end users.<\/p>\n<p>For more information, please contact us at <a href=\"mailto:salesforce@greytrix.com\">salesforce@greytrix.com<\/a>. We will be glad to assist you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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.\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2017\/07\/20\/sending-email-attachment-using-vf-email-template\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[29,110,367,522],"class_list":["post-2583","post","type-post","status-publish","format-standard","hentry","category-salesforce-srv","tag-attachment","tag-email-template","tag-salesforce","tag-visualforce"],"_links":{"self":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts\/2583","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/comments?post=2583"}],"version-history":[{"count":4,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts\/2583\/revisions"}],"predecessor-version":[{"id":10668,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts\/2583\/revisions\/10668"}],"wp:attachment":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/media?parent=2583"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/categories?post=2583"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/tags?post=2583"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}