{"id":2423,"date":"2017-03-29T07:24:01","date_gmt":"2017-03-29T07:24:01","guid":{"rendered":"http:\/\/www.greytrix.com\/blogs\/salesforce\/?p=2423"},"modified":"2025-06-12T09:22:37","modified_gmt":"2025-06-12T09:22:37","slug":"send-an-email-with-attachment-from-salesforce","status":"publish","type":"post","link":"https:\/\/www.greytrix.com\/blogs\/salesforce\/2017\/03\/29\/send-an-email-with-attachment-from-salesforce\/","title":{"rendered":"Send an Email with Attachment from Salesforce"},"content":{"rendered":"<p style=\"text-align: justify;\">This blog signifies how Salesforce user can send Email from Salesforce using the custom methods and design the Email layout as per their choice. User can develop email templates or craft an email with the help of apex code. For sending the mail the user can utilize triggers, workflow rules or process builder as per their wish. But what if the user wishes to send an email along with the attachment. Well, this is where Salesforce is currently falling short.<\/p>\n<p class=\"mb-xl align-center\"><strong><a href=\"https:\/\/www.greytrix.com\/product\/crm-development\/salesforce-com\"><em>Get more from Salesforce CRM <\/em><em>|\u00a0<\/em><em>Salesforce Development Services<\/em><\/a><\/strong><\/p>\n<p style=\"text-align: justify;\">Although the user can send an email from Salesforce by using various methods, sending an email along with attachments is not quite possible. So, here&#8217;s a step by step guide on how to send an email along with attachments from Salesforce. The components that we will require for this functionality is a VisualForce page and an Apex class.<\/p>\n<p>1. Create an Apex class and use the code mentioned in the below image.<\/p>\n<div id=\"attachment_2425\" style=\"width: 728px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/03\/1.-Apex-class.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img fetchpriority=\"high\" decoding=\"async\" aria-describedby=\"caption-attachment-2425\" class=\" wp-image-2425\" style=\"border: 1px solid #A9A9A9; padding: 2px; margin: 2px;\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/03\/1.-Apex-class.png\" alt=\"Apex class\" width=\"718\" height=\"554\" \/><\/a><p id=\"caption-attachment-2425\" class=\"wp-caption-text\">Apex class<\/p><\/div>\n<div id=\"attachment_2426\" style=\"width: 730px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/03\/2.-Apex-class.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" aria-describedby=\"caption-attachment-2426\" class=\" wp-image-2426\" style=\"border: 1px solid #A9A9A9; padding: 2px; margin: 2px;\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/03\/2.-Apex-class.png\" alt=\"Apex class\" width=\"720\" height=\"516\" \/><\/a><p id=\"caption-attachment-2426\" class=\"wp-caption-text\">Apex class<\/p><\/div>\n<p>2. Now for VisualForce page, use the below mentioned code.<\/p>\n<div id=\"attachment_2427\" style=\"width: 685px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/03\/3.-Visualforce-page.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" aria-describedby=\"caption-attachment-2427\" class=\"size-full wp-image-2427\" style=\"border: 1px solid #A9A9A9; padding: 2px; margin: 2px;\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/03\/3.-Visualforce-page.png\" alt=\"Visualforce page\" width=\"675\" height=\"451\" \/><\/a><p id=\"caption-attachment-2427\" class=\"wp-caption-text\">Visualforce page<\/p><\/div>\n<p>The apex class consists of logic that will store the attachment and then send the mail accordingly. The VisualForce page is a mere interface which simply helps in implementing the functionality.<\/p>\n<p>The user enters the email address in the field \u201cSend To\u201d and then enters the respective Subject and the body of the mail. The user then clicks on \u201cBrowse\u201d to select the file to be sent as an attachment and then the user clicks on \u201cAttach &amp; Send\u201d. Once the user clicks on this button the attachment selected gets stored\/inserted into Document object and the mail is sent along with attachment to the mentioned email address.<\/p>\n<div id=\"attachment_2428\" style=\"width: 549px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/03\/4.-Interface.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2428\" class=\"size-full wp-image-2428\" style=\"border: 1px solid #A9A9A9; padding: 2px; margin: 2px;\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/03\/4.-Interface.png\" alt=\"Interface\" width=\"539\" height=\"449\" \/><\/a><p id=\"caption-attachment-2428\" class=\"wp-caption-text\">Interface<\/p><\/div>\n<div id=\"attachment_2429\" style=\"width: 549px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/03\/5.-Email.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2429\" class=\"size-full wp-image-2429\" style=\"border: 1px solid #A9A9A9; padding: 2px; margin: 2px;\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/03\/5.-Email.png\" alt=\"Email\" width=\"539\" height=\"445\" \/><\/a><p id=\"caption-attachment-2429\" class=\"wp-caption-text\">Email<\/p><\/div>\n<div id=\"attachment_2430\" style=\"width: 633px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/03\/6.-Email-recieved-by-the-recipient.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2430\" class=\"size-full wp-image-2430\" style=\"border: 1px solid #A9A9A9; padding: 2px; margin: 2px;\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2017\/03\/6.-Email-recieved-by-the-recipient.png\" alt=\"Email recieved by the recipient\" width=\"623\" height=\"317\" \/><\/a><p id=\"caption-attachment-2430\" class=\"wp-caption-text\">Email recieved by the recipient<\/p><\/div>\n<p><span style=\"font-size: Medium;\"><strong>About Us<\/strong><\/span><br \/>\n<a href=\"https:\/\/www.greytrix.com\/\">Greytrix<\/a>\u00a0as a Salesforce Product development partner offers a wide variety of integration products and services to the end users as well as to the Partners across the globe. We offers Consultation, Configuration, Training and support services in out-of-the-box functionality as well as customizations to incorporate custom business rules and functionalities that requires apex code incorporation into the Salesforce platform.<\/p>\n<p><a href=\"https:\/\/www.greytrix.com\/\">Greytrix<\/a>\u00a0has some unique solutions for Cloud CRM such as Salesforce integration with\u00a0<a href=\"https:\/\/www.greytrix.com\/product\/sage-x3\/gumu-x3-salesforce-integration\">Sage Enterprise Management (Sage X3<\/a>),\u00a0Sage Intacct, <a href=\"https:\/\/www.greytrix.com\/product\/sage-100-erp\/gumu-100-salesforce-integration\">Sage 100\u00a0<\/a>and\u00a0<a href=\"https:\/\/www.greytrix.com\/product\/sage-300-erp\/gumu-300-salesforce-integration\">Sage 300 (Sage Accpac)<\/a>. We also offer best-in-class Cloud CRM\u00a0<a href=\"https:\/\/www.greytrix.com\/product\/crm-development\/salesforce-com\">Salesforce customization and development services<\/a> along with services such as Salesforce <a href=\"https:\/\/www.greytrix.com\/product\/professional-services\/data-migration-services\">Data Migration<\/a>, <a href=\"https:\/\/www.greytrix.com\/product\/professional-services\/integrated-application-development\">Integrated App development<\/a>, <a href=\"https:\/\/www.greytrix.com\/product\/professional-services\/custom-development\">Custom App development<\/a> and <a href=\"https:\/\/www.greytrix.com\/product\/professional-services\/maintenance-support\">Technical Support<\/a> to business partners and end users.<\/p>\n<p>Greytrix GUMU&#x2122; integration for Sage ERP \u2013 Salesforce is a 5-star app listed on <a href=\"https:\/\/appexchange.salesforce.com\/listingDetail?listingId=a0N30000000psM5EAI\" target=\"_blank\" rel=\"noopener\">Salesforce AppExchange<\/a>.<\/p>\n<p>For more information, please contact us at\u00a0<a href=\"mailto:salesforce@greytrix.com\">salesforce@greytrix.com<\/a>. We will be glad to assist you.<\/p>\n<p><span style=\"font-size: Medium;\"><strong>Related Posts<\/strong><\/span><\/p>\n<ul>\n<li><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2016\/12\/29\/addingcreating-fieldset-in-salesforce\/\" target=\"_blank\" rel=\"noopener noreferrer\">Adding\/Creating Feildset in Salesforce.<\/a><\/li>\n<li><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2017\/03\/28\/translate-picklist-into-multiple-languages\/\" target=\"_blank\" rel=\"noopener noreferrer\">Translate Picklist into Multiple Languages<\/a><\/li>\n<li><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2017\/03\/28\/access-frequently-used-salesforce-pages-reports-dashboards-and-others-by-using-shortcuts\/\" target=\"_blank\" rel=\"noopener noreferrer\">Access frequently used Salesforce pages, Reports, Dashboards and others by using shortcuts<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>This blog signifies how Salesforce user can send Email from Salesforce using the custom methods and design the Email layout as per their choice. User can develop email templates or craft an email with the help of apex code. For sending the mail the user can utilize triggers, workflow rules or process builder as per\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2017\/03\/29\/send-an-email-with-attachment-from-salesforce\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[859,895,894,108,890,266,384,385,392,394,888,892,889,891,893],"class_list":["post-2423","post","type-post","status-publish","format-standard","hentry","category-salesforce-srv","tag-apex-class","tag-apex-triggers","tag-classic-email-templates","tag-email-attachment","tag-email-file-attachment","tag-process-builder","tag-salesforce-auto-email","tag-salesforce-auto-email-attachments","tag-salesforce-development","tag-salesforce-email-attachment","tag-salesforce-emailtemplate","tag-send-email-via-salesforce","tag-singleemailmessage","tag-visualforce-page-for-email","tag-workflow-rules"],"_links":{"self":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts\/2423","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=2423"}],"version-history":[{"count":10,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts\/2423\/revisions"}],"predecessor-version":[{"id":10925,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts\/2423\/revisions\/10925"}],"wp:attachment":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/media?parent=2423"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/categories?post=2423"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/tags?post=2423"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}