This article shows how to send email with attachments in a Salesforce flow.
Send Email Action
In the release of Spring '25, the "Attachment ID" parameter has been added to the Send Email action. ContentVersion.Id, Attachment.Id, or Document.Id are available for the parameter.
Retrieve Files Attached to the Record
File
The file data is stored in ContentVersion. The reference relationship between the record and the file is stored in the LinkedEntityId of the ContentDocumentLink.
To retrieve the file attached to the record is the below.
- Get ContentDocumentId from ContentDocumentLink
Get ContentDocumentId from ContentDocumentLink that matches recordId = LinkedEntityId.
- Get ContentVersion
Get ContentVersion matching ContentDocumentId = retrieved ContentDocumentId.
Attachment
The reference relationship between the record and the attachment is stored in the ParentId.
Flow Overview
As an example, the flow is to send an email with a file attached to the case record from the case screen.
Sending Patterns of Emails
There are two patterns for sending an email in the "Send Email" action.
a. Set the subject, body, and email address (not use the email template and recipient Id).
b. Set the email template and recipient Id (Contact/Person Account/Lead).
Send Emal with Attachments Flow (By Subject, Body, and E-mail Address)
Create a flow to send an email with an attachment by subject, body, and email address.
Top Screen
Display the confirmation message on the screen.
Get Case
Get the Case record.
Get ContentDocumentLink
Get the ContentDocumentLink matching LinkedEntityId = recordId.
Get ContentVersion
Get the ContentVersion that matches the ContentDocumentId retrieved from the ContentDocumentLink. In this sample, only one file is related to the case. If there are multiple attached files, other conditions such as matching Title are required.
ContentDocumentId = {!GetContentDocumentLink.ContentDocumentId}
Create a Variable for the Email Body
Create a variable for the email body. Select "Text Template" for the resource type. Select "View as Plain Text" for the body.
Send Email with Attachment
Call the Send Email action.
Attachment ID: {!GetContentVersion.Id} *ContentVersion.Id
Body: {!txttempBody} *Text Template Variable
Recipient Address List: {!GetCase.SuppliedEmail} *Case.SuppliedEmail (Web Email)
Related Record ID: {!recordId}
Sender Email Address: Org email address *In this sample, the sender is the organization's email address.
Sender Type: OrgWideEmailAddress *In this sample, the sender is the organization's email address.
Subject: Send a quotation
Send Emal with Attachments Flow (By Email Template and Recipient Id)
Create a flow to send an email with an attachment by the email template and recipient Id (Contact/Person Account/Lead). The process from the Top screen to the Get ContentVersion is the same as the previous flow.
Get EmailTemplate
Get EmailTemplate. In this sample, use the email template for the quote.
DeveloperName = SendQuoteEmail
Send Email with Attachment
Call the Send Email action.
Attachment ID: {!GetContentVersion.Id} *ContentVersion.Id
Email Template ID: {!GetEmailTemplate.Id} *EmailTemplate.Id
Log Email on Send: {!$GlobalConstant.True}
Recipient Id: {!GetCase.ContactId} *Case.ContactId
Related Record ID: {!recordId}
Sender Email Address: Org email address *In this sample, the sender is the organization's email address.
Sender Type: OrgWideEmailAddress *In this sample, the sender is the organization's email address.
Reference
Salesforce Help: Flow Core Action: Send Email
Send an Email with a PDF Quote in Salesforce Record-Triggered Flow - Office File Creator Advanced -