Loading
Salesforce now sends email only from verified domains. Read More
Ongoing maintenance for Salesforce HelpRead More
Automate Your Business Processes
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          Send an Email with Attachments in a Record-Triggered Flow Example

          Send an Email with Attachments in a Record-Triggered Flow Example

          When your sales team is ready to send out proposal documents to the contacts involved with the opportunity, use this example flow to automatically send an email with the attachments to those contacts. This flow stores the attachment IDs in a collection variable and then passes the collection variable into the Send Email action's attachment ID collection field.

          Required Editions

          View supported editions.
          User Permissions Needed
          To view and edit opportunity:
          • Read on Opportunity
          • Edit on Opportunity
          To upload attachments to an opportunity:
          • Read on ContentDocumentLink
          • Create on ContentDocumentLink
          To add contact roles:
          • Read on OpportunityContactRole
          • Create on OpportunityContactRole
          To open, edit, create, activate or deactivate a flow using all flow types, elements, and features available in Flow Builder, including Einstein and Agentforce for Flow: Manage Flow
          Important
          Important To send email from Salesforce, the Send Email action in Salesforce Flow requires domain-level and user-level email verification. Email delivery fails if either the user's email address or the email-sending domain is unverified. See Requirements to Send Email from Salesforce.

          Upload Attachments to an Opportunity and Add Contact Roles

          1. From the App Launcher, find and select Opportunities.
          2. To upload attachments to an opportunity, find the opportunity in the opportunities related list and edit it.
          3. Upload your files under Notes and Attachments (1).
            An opportunity record that shows an opportunity's contact roles and attachments.
          4. To send an email to contact roles when this opportunity is updated, add them under Contact Roles (2).

          Create a Record-Triggered Flow

          1. Open the Flows list view.
            • From Setup, in the Quick Find box, enter Flows, and then select Flows.
            • From the Automation app, select the Flows tab.
            • From the Flows tab in any Lightning app, click the actions menu and select Open Flow.
          2. Create a record-triggered flow.
          3. To trigger the flow whenever the opportunity record is updated and the opportunity is at the Proposal/Price Quote stage, complete these steps:
            1. Under Select Object, select Opportunity.
            2. Under Configure Trigger, select A record is updated.
            3. Under Condition Requirements, select All Conditions Are Met (AND).
            4. Set the Stage field to equal Proposal/Price Quote.

          Create a Text Collection Variable to Store Attachment IDs

          1. To create a new resource, go to the Manager tab in the Flow Builder toolbox, and then click New Resource.
          2. From the Resource Type dropdown menu, select Variable.
          3. In the API Name field, enter ContentDocumentIDs.
          4. From the Data Type dropdown menu, select Text.
          5. Select Allow multiple values (collection).
          6. Save your changes.

          Iterate over Every Content Document Link and Assign the Attachment ID to a Collection Variable

          1. Add a loop element after the Get Records element.
          2. For the label, enter Iterate Over Content Document Links.
          3. Set the Collection Variable to Content Document Link from Get Content Document Links.
          4. Add an assignment element so it's triggered for each iteration of the loop.
          5. In the label field, enter Add Document ID to Collection.
          6. To set the variable value:
            1. Under Variable, select ContentDocumentIDs.
            2. Under Operator, select Add.
            3. Under Value, select Current Item from Loop Iterate Over Content Document Links | Content Document ID | Latest Published Version ID{!Iterate_Over_Content_Document_Links.ContentDocument.LatestPublishedVersionId}
              AN assignment element that assigns the latest published version ID to the content document IDs variable.

          Get the Opportunity ID for the Opportunity Contact Roles Associated with the Triggering Opportunity

          1. Add a Get Records element after the Iterate Over Content Document Links loop element.
          2. For the label, enter Get Opportunity Contact Roles.
          3. For the object, select Opportunity Contact Role.
          4. Under Filter Opportunity Contact Role Records:
            1. Under Condition Requirements, select All Conditions are Met (AND).
            2. Set the Opportunity ID field to equal Triggering Opportunity ID | Opportunity ID.
            3. Under How Many Records to Store, select All Records.
            1. Under How to Store Record Data, select Automatically store all fields.

          Create a Text Collection Variable to Store the Email Addresses of the Contact Roles

          1. To create a new resource, go to the Manager tab in the Flow Builder toolbox, and then click New Resource.
          2. From the Resource Type dropdown menu, select Variable.
          3. In the API Name field, enter ContactEmailAddresses.
          4. From the Data Type dropdown menu, select Text.
          5. Select Allow multiple values (collection).
          6. Save your changes.

          Iterate over Every Opportunity Contact Role and Assign the Email Address to a Collection Variable

          1. Add a loop element.
          2. For the label, enter Iterate Over Opportunity Contact Roles.
          3. Set the Collection Variable to Opportunity Contact Role from Get Opportunity Contact Roles.
          4. Add an assignment element so it's triggered for each iteration of the loop.
          5. For the label, enter Add Contact Email Addresses to Collection.
          6. To set the variable value:
            1. Under Variable, select ContactEmailAddresses.
            2. Under Operator, select Add.
            3. Under Value, go to Current Item from Loop Iterate Over Opportunity Contact Roles > Contact ID > Email ID{{!Iterate_Over_Opportunity_Contact_Roles.Contact.Email}}
              An assignment element where the contact role email ID is assigned to the contact email addresses variable.

          Send Email with Attachments to Opportunity Contacts

          1. Add a Send Email action after the Iterate Over Opportunity Contact Roles loop element.
          2. For the label, enter Send Email to Contacts.
          3. Under Recipient Addresses, select ContactEmailAddresses.
          4. For the Subject, enter the text Please review your proposal documents.
          5. For the Body, enter the rich text Hello! Please review these proposal documents for the {$Record.Name} deal. Thank you!
          6. Under Rich-Text-Formatted Body, select True.
          7. In the Attachment ID Collection field, select ContentDocumentIDs.
            The send email action that includes a rich text body and an attachment ID collection variable.
          8. Save the record-triggered flow.
          9. Activate the flow.
          10. Move the opportunity with the uploaded attachments to the Proposal/Price Quote stage.
            All the contact record roles associated with the opportunity receive an email after the opportunity moves to the Proposal/Price Quote stage.
            Important
            Important After migrating flows, always review and reconfigure the Send Email action to reference the new record IDs in the target Salesforce org. This step is crucial to avoid broken references and ensure that email delivery functions correctly.
           
          Loading
          Salesforce Help | Article