Loading
Salesforce now sends email only from verified domains. Read 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 an Attachment in an Autolaunched Flow Example

          Send an Email with an Attachment in an Autolaunched Flow Example

          Use the Send Email action to send an email with an attachment to all employees living in a city. For example, you want to send an important update to all employees living in San Francisco and add attachments to your email.

          Required Editions

          View supported editions.
          User Permissions Needed
          To view Files tab: Read on files
          To upload new files: Create on files
          To replace files: Edit on files
          To edit process automation settings: Customize Application
          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
          Note
          Note If you're following along in an existing flow, make sure the Send Email action version is set to 1.0.1.
          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 a File and Create an Autolaunched Flow

          1. In the App Launcher, search for and select Files.
          2. To upload a file, click Upload Files, choose the file, and then click Open.
            Important
            Important To ensure that the flow completes successfully, make sure that the email, including all attachments, doesn't exceed the 35 MB limit.
          3. Click Done.
          4. 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.
          5. Create an autolaunched flow.
            • From the Automation app, click , then click New | Autolaunched | Autolaunched Flow (No Trigger).
            • From Setup, click New Flow | Autolaunched | Autolaunched Flow (No Trigger).

          Create and Configure a Record Collection Variable

          1. In the Toolbox, in Manager, click New Resource.
          2. From the Resource Type dropdown, select Variable.
          3. For API Name, enter employeesInSF.
          4. For Data Type, select Record and select Allow multiple values (collection).
          5. For Object, enter user and select User.
          6. For Availability Outside the Flow, select both Available for input and Available for output.
            A variable resource properties panel with the Data Type field set to Record and the Object field set to User.

          Create and Configure a Text Collection Variable

          1. In the Toolbox, in Manager, click New Resource.
          2. From the Resource Type dropdown, select Variable.
          3. For API Name, enter email_employeesInSF.
          4. For Data Type, select Text and select Allow multiple values (collection).
          5. For Availability Outside the Flow, select both Available for input and Available for output.
            A variable resource properties panel with the Data Type field set to Text.

          Add a Get Records Element

          1. Click Add element plus icon, and select Get Records.
          2. For Label, enter Find SF Employees.
          3. For Object, select User.
          4. For Condition Requirements, select All Conditions Are Met (AND).
          5. For Field, click City. For Operator, click Equals. For Value, enter San Francisco.
          6. For How Many Records to Store, select All Records.
          7. For How to Store Record Data, select Choose fields and assign variables (advanced).
          8. For Record Collection, select the employeesInSF record collection variable.
          9. For Field, select Email.
            Get Records element configuration

          Add and Configure Loop and Assignment Elements

          1. After the Get Records element, add and configure a Loop element.
            1. Click Add element plus icon, and select Loop.
            2. For Label, enter Loop Through Employee.
            3. For Collection Variable, click employeesInSF.
            Loop element configuration with the Collection Variable field set to the employeesInSF record collection variable.
            If you have a large number of items in your collection variable, you may experience performance issues when processing the collection. For example, processing 20,000 records in a record collection using a Loop element can significantly delay the flow run. To enhance efficiency, configure your flow to handle fewer items at a time. You can achieve this by splitting a large collection into two collection variables or by narrowing the filter criteria for adding records to the collection variable.
          2. After the For Each node of the Loop element, add and configure an Assignment element.
            1. Click Add element plus icon, and select Assignment.
            2. For Label, enter Add Email to Collection Variable.
            3. In Set Variable Values, for Variable, click email_employeesInSF. For Operator, click Add. For Value, click Loop Through Employee and then click Email.
            Assignment element configuration

          Add and Configure Send Email Action

          1. Click Add element plus icon, and select Action.
            A list of available actions opens.
          2. In the search bar, enter Send Email, and then click Send Email.
            For more information about the Send Email action, see Flow Core Action: Send Email.
          3. For Label, enter Email SF Employees and use the default API name, Email_SF_Employees.
          4. For Recipient Addresses, click email_employeeInSF.
          5. Click Compose Email Content.
          6. For Subject, enter the text Important Update for San Francisco Employees.
          7. For Body, enter the rich text Dear. Then, to insert the User's First Name, click Insert a resource... | Running User | First Name.
          8. Enter the remaining email body content as:
            We hope this message finds you well. We have an important update for all employees based in San Francisco.
            [Insert your message here. This could be about a new policy, an upcoming event, or any other relevant information.]
            Please make sure to review the details and reach out if you have any questions or need further assistance.
            Best regards,
            [Your Name]
            [Your Position]
            [Your Contact Information]
          9. For the Rich-Text-Formatted Body value, click True.
          10. For the Attachment ID, search for and click the files that you previously uploaded.

          Troubleshoot the Flow

          1. To troubleshoot the flow for errors, save the flow, and then click Debug.
          2. Click Run.
            The debug details for the run appear in a panel.
          3. To make sure that the attached files you uploaded are included, verify the email.

          When you're confident that your flow is working as expected, activate and distribute the version that you tested.

          Sample flow that sends an email with attachments to the San Francisco employees.
          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