Receive emails to a Salesforce address, and use Flow to define the logic of how to handle the email once it has been received.
Salesforce has the ability to create custom email addresses which allow custom processing once the email has been received. Think Email-to-Case - but instead, Email-to-Anything. Normally, to receive emails into Salesforce and create any automation based on the email, Apex code must be created.
The purpoase of this package is to empower Declarative Developers (AKA Flownatics AKA Salesforce Administrators) to create the same capabilities.
The package includes:
- Apex Class (EmailToFlow) and Test Class
- Platform Event called 'Email to Flow Received'
- Sample Flow you can use as a starting point.
Once an email is received:
- The Apex Class will handle the receipt of the email:
- Create ContentVersion record for each attachment included in the email
- Publish a Platform Event, including all relevant Email Details
- Platform-Event Triggered Flow is used to then perform any logic that should occur (create records, send notifications, or whatever else you can dream of)
Any user who should be able to set up processing flows, or which acts as the Context User for the Email Service (see below), must have the 'EmailToFlow User/Admin' Permission Set assigned to them. This permission set provides Create and Read access to the Platform Event and to the Apex Class.
In order to use this tool, you need to set up an Email Service in Salesforce, and select the EmailToFlow Apex Class:
- Navigate to Setup > Custom Code > Email Service
- Click New
- Give the Service a name
- Select the EmailToFlow Apex Class
- Ensure the Active checkbox is checked
Once the Email Service has been setup, we need to create at least one Service Email Address - that will be the unique (and very long) email address to which emails should be sent or forwarded.
- Give the address an API name
- Enter the 'local part' of the email address (i.e. the part before the @ sign)
- Ensure the Address is Active
- Select the Context User - that will be the user which the Apex Class will operate as
- Optional: Set or remove the 'Accept Email From' list. Empty means anyone can send emails to this address, populated means only emails from addresses listed here can be accepted.
Once the Email Service has been setup, when an email is received to the Service Address, the Apex Class will publish a Platform Event, to which a Flow should be Subscribed to (another way to say that the Flow is Platform-Event Triggered off this event type) The Flow can do whatever you need it to do - so you can start from a brand new flow if you want. However, the package includes a Sample flow titled 'Email to Flow - Sample Flow for Email Handling'. You can use this flow as a starting point and make changes as you see fit.
The flow is designed to:
- Accept an Email to a specific Email Service Address
- Create a Case
- Create an Email Message and associate it with the case
- Link any file attachments to the Case
- Send an Auto-Response email
Worth Noting that the flow uses a non-traditional loop pattern, where instead of using a Loop element, we use a 'Connect to Element' node to extract values from a Comma-separated string, until that string is Empty. You can use other mechanisms to convert a Comma-separated string to a collection, such as custom Apex Actions, or the UnOfficial Salesforce's Convert Strings to String Collections, and Vice Versa Apex Action. This will allow you to replace 4 elements with a single Apex Action.
To install this component, use one of the following links:



