Skip to main content

Email to Flow

The Email to Flow feature enables Flows to process inbound emails. Salesforce Admins can often set up this feature in ten minutes or less. Below are the setup instructions and documentation on accessing data from the inbound email in a Flow, including the subject, body, recipients, file attachments, and more.

Setup

Setting up Email to Flow requires three steps: 1) setting up an email service and email address, 2) creating a flow with an InboundEmail variable, and 3) mapping the Email Service to the Flow. Instructions to complete these steps are below but don't hesitate to contact support if you have any questions about setting up this feature.

Create an Email Service

In Salesforce Setup, navigate to the Email Services section and create a New Email Service. Ignore the notification saying an Apex class must be created first. The Flow Pack Pro app will handle this requirement.

Name the Email Service and in the Apex Class input, select the EmailToFlow class from the flowpackpro namespace.

See this page from Salesforce on configuring other options, https://help.salesforce.com/s/articleView?id=sf.code_email_services_editing.htm&type=5

Create a related Email Address for the Email Service.

Make sure the Email Address is active, set the running Context User, and clear the Accept Email From input to receive email from all email addresses.

After saving the address, note the long email address that has been generated. Emails sent to this email address will be processed in the Flow we will create in the next section.

To create a user-friendly email, you will need to work with your IT department or email provider and create an email alias that forwards all emails to the long Email Service address.

Create a Flow

Create a new Autolaunched Flow that will process the inbound email.

Create a new Variable with the following settings.

info

The API Name of the variable is case-sensitive and must have an exact value of: InboundEmail

In the Flow, you can access the values from the inbound email by using the InboundEmail variable in the flow. See the Apex-Defined InboundEmail Type for all of the email properties available.

You can continue to build custom business logic to handle the inbound email.

tip

Keep the logic and processing in this Flow as simple as possible. If your Flow fails, the inbound email will not be processed again.

Map Email Service to the Flow

The final step is to map the Email Service to the Flow that includes the InboundEmail variable. Navigate to the Flow Pack Pro Setup tab and select the Email to Flow section. Select which Flow should be invoked from the dropdown list for a given Email Service.

Activate the flow and send emails to the Email Service address to test this flow.

Apex-Defined Type

InboundEmail

The InboundEmail variable contains the following values that can be used in a Flow.

NameTypeDescription
attachmentsRecord Collection (ContentVersion)Attachments from the email converted to a ContentVersion record collection. User the Create File action to insert the files.
caseIdTextThe Case ID, if the email is a reply to a Case.
ccAddressesText CollectionA list of carbon copy (CC) addresses, if any.
fromAddressTextThe email address that appears in the From field.
fromNameTextThe name that appears in the From field, if any.
hasAttachmentsBooleanSet to true if the email has attachments.
headersMapCollectionMapCollectionA Map Collection of the email headers. Use the Get Text From Map to retrieve values.
htmlBodyIsTruncatedBooleanIndicates whether the HTML body text is truncated (true) or not (false.)
inReplyToTextThe In-Reply-To field of the incoming email. Identifies the email or emails to which this one is a reply (parent emails). Contains the parent email or emails' message-IDs.
messageIdTextThe Message-ID—the incoming email's unique identifier.
plainTextBodyTextThe plain text version of the email, if specified by the sender.
plainTextBodyIsTruncatedBooleanIndicates whether the plain body text is truncated (true) or not (false.)
recipientAddressesText CollectionA list of email addresses including both the To and CC addresses.
referencesText CollectionThe References field of the incoming email. Identifies an email thread. Contains a list of the parent emails' References and message IDs, and possibly the In-Reply-To fields.
replyToAddressTextThe email address that appears in the reply-to header.
subjectTextThe subject line of the email, if any.
toAddressesText CollectionThe email address that appears in the To field.