Salesforce Flow is a powerful automation tool that helps users reduce manual work and improve efficiency. One of the most useful features in Flow is the ability to send emails automatically.
In many real-world scenarios, users need to send emails along with attachments such as invoices, offer letters, reports, or documents. Instead of attaching files manually each time, Salesforce lets us send emails with dynamic attachments via Flow.
Dynamic attachments mean that the file is not fixed in advance. Instead, the system automatically picks the correct file based on the record and sends it with the email. This fully automates the process and eliminates manual effort.
For example, when a candidate is selected in a recruitment system, the offer letter uploaded to their record can be automatically emailed. This type of automation improves productivity and reduces human errors.
The recruitment team at our company wants to automate the sending of offer letters to candidates when their candidate record status changes to “Selected” in Salesforce.
Earlier, when sending the offer email, the team had to manually attach the offer letter each time.
I created a record trigger flow to automate this process, so the team doesn’t need to attach the offer letter. The flow will dynamically attach it and send it to the candidate.
In this article, we will learn how to send email with Dynamic Attachments in Salesforce Flow. In that, I will explain how we can upload a file to the record, and that file will be taken from the object and attached to the email.
What is Dynamic Attachment in Salesforce Flow?
Dynamic attachment in Salesforce Flow means attaching files to an email dynamically based on the record data. Instead of manually selecting a file, the Flow automatically retrieves the file associated with a record and includes it in the email.
Salesforce stores files using objects like:
- ContentDocument
- ContentVersion
- ContentDocumentLink
When a file is uploaded to a record, it is linked through these objects. Flow uses this relationship to fetch files and attach them to emails.
This feature became easier with the introduction of the Send Email action, which allows adding attachment IDs directly.
Send An Email with Dynamic Attachments in Salesforce Flow
First, we will review the prerequisites, then learn how to create a flow to automate sending an email with a dynamic attachment in Salesforce.
1. Prerequisites:
First, the recruitment team member should upload the offer letter to the selected candidate’s profile.
Whenever a candidate is selected for the company, the recruitment team marks the status as ‘offer pending.’
When the manager approves the offer, the flow dynamically sends the offer letter to the candidate’s email.

2. Create Record Trigger Flow in Salesforce:
Click on the Setup. -> Home Page. -> In Quick Find Box, Search for Flows. You will see an option under Process Automation. -> Click on Flows.
In the flows setup window, click on the button New Flow -> Start From Scratch -> select the Record Trigger Flow -> Next.
In the start element, we need to select the object we want to automate. In our scenario, the Candidate Profile is a triggering object.
In the Configure Trigger, select ‘A record is created or updated’.
Now add the condition when the flow should get triggered:
- The offer status should be marked as ‘offer pending’.
- The manager should approve the offer.

Now we need to create a Resource Type Variable to store the attachment IDs we want to send with the email to the candidate.
Provide the API Name, Data Type as Text, and make it available for both input and output. Then, click the Done button.

We now need to retrieve all documents linked to the candidate record. In Salesforce, documents are stored in the Content Document Link object.
Then, to Filter Records for the object, we need to add a condition:
- In the Field option, you will see all fields from the Content Document Object. There, we need to select the Linked Entity ID.
- Equals operator.
- In the Value field, select the Candidate Record ID from the Candidate Profile object.
This condition fetches the documents for the respective candidates, and since we want to retrieve all candidate records, we need to store all records.

Now, we will use the loop element to iterate over the records retrieved by the get record element. To add the Loop Element, click on the Add Element icon.
Then, enter the element Label and API Name.
Then, select the Collection Variable Get Records (API Name), and set the iteration direction to first to last.

In this step, we will add the ‘Document ID’ from the current record of the loop element to the created variable (Offer_Letter_IDs) to store the offer letters.
To do so, add the Assignment Element. Then, enter the element Label and API Name.
Here in the Set variable Values, I added a condition as follows:
- Offer_Letter_IDs -> Add -> Loop > {!Loop_Through_Files.ContentDocument.LatestPublishedVersionId}: Here, we store the content document ID in the variable created for the collection.
- Then, if you have multiple documents to send, you need to add a comma (,) to separate documents while adding to the variable.

Now, let’s create the email body where we can add the text we want to send.
To do this, in the Resource Type section, select Text Template, enter the API Name, and customize the body as needed.

After that, we would like to send an email to the candidate to notify them that they have been offered a position. For that, add the Send Email action.
Then, provide the values for the send email action as follows:
- Recipient Address List: Provide the candidate’s email address from the object.
- Sender Email Address: This can be either the current user’s email address or the record owner’s email address.
- Subject: You can provide a hardcoded subject.
- Body: Please provide the text template we created for the email body.
- Attachment ID: To access the attachment dynamically, instead of providing the document ID, we will use the Variable (Offer_Letter_IDs) that we created, which stores the document IDs of the respective candidates.

Now we are ready to save the flow. For that, click the Save button, provide the flow Label, and the API Name will be automatically populated.
After that, always debug the flow before activating it to ensure that the working flow is correct and that there are no runtime errors. Then activate the flow.

3. Proof of Concept:
After activating the flow, navigate to the Candidate Profile tab to update a record that will trigger the flow.
Set the Status field to ‘Offer Pending‘ and check the Manager Approved checkbox according to the condition defined in the flow.
Then save the changes.

As you save the record, check the candidate’s email to see whether they received the email with the email body and subject you provided in the flow.
Also, you will see that the attachment you uploaded to the record was also received in your email.

In this way, we can send a dynamic attachment with an email using Salesforce Flow.
Conclusion
Sending emails with dynamic attachments in Salesforce Flow is a powerful automation feature that helps businesses streamline their processes.
Instead of manually attaching files, users can automate the entire workflow using Flow. This not only saves time but also improves efficiency and reduces errors.
By understanding how Salesforce stores files and how Flow interacts with them, you can build advanced automation solutions for real-world use cases.
Whether it is recruitment, invoicing, or customer communication, dynamic attachments can significantly improve your business operations.
You may like to read:
- Create and Send a PDF Via Email Using Salesforce Flow
- Use a Data Table in Salesforce Screen Flow
- Clone Salesforce Flows
- Send Email Alerts For Overdue Tasks Using Salesforce Flows
- Send Custom Notifications Using Salesforce Flow

Shubham is a Certified Salesforce Developer with technical skills for Building applications using custom objects, approval processes, validation rule salesforce flows, and UI customization. He is proficient in writing Apex classes, triggers, controllers, Apex Batches, and bulk load APIs. I am also familiar with Visualforce Pages and Lighting Web Components. Read more | LinkedIn Profile