You are here:
Get Account and Opportunity from Email Addresses Action
This action gets an account record associated with a contact or unmatched email address and also gets an opportunity record related to a contact. To be used in the Activities: Match Email to Records flow. Requires that Sync Email as Salesforce Activity is enabled in Einstein Activity Capture.
Required Editions
| Available in: Lightning Experience |
| Available with Einstein Activity Capture Standard in Sales Cloud in Starter, Professional, and Enterprise Editions |
| Available with Unlimited Edition and Einstein 1 Sales Edition |
| Available with Einstein for Sales, which is included in Einstein 1 Sales Edition, and available for an extra cost in Enterprise and Unlimited Editions. |
| Available with Sales Engagement in Sales Cloud, which is included in Performance and Unlimited Editions, and available for an extra cost in Professional and Enterprise Editions. |
| Available with Revenue Intelligence, which is available for an extra cost in Enterprise and Unlimited Editions. |
In Flow Builder, add an Action element to your flow. In the New Action window, search for Activities Match, and then select Get Account and Opportunity from Email Addresses.
Set Input Values
Use values from earlier in the flow to set the inputs for the action.
| Field | Description |
|---|---|
| Account Field | The name of the field you use to identify partner accounts. Optional if Partner
Accounts is false. This input is captured in the Uses Partner
Accounts section of action properties in Flow Builder. |
| Activity Date | Required. The date and time of the activity. For email, it’s the date the email was sent. |
| Comparison Operator | The comparison operator to determine a partner account. Valid values are
Equals, Does Not Equal, Greater Than, Less Than, Greater Than or Equal, Less Than or
Equal, Is Null, and Is Blank. Optional if Partner Accounts is
false. This input is captured in the Uses Partner Accounts section
of action properties in Flow Builder. |
| Contacts | Required. A collection of contact records to get associated account and opportunity records for. |
| Partner Accounts | A Boolean value that indicates whether the business has partner accounts. The
default value is false. This input is captured in the Uses Partner
Accounts section of action properties in Flow Builder. |
| Unmatched Email Addresses | Optional. A collection of email addresses that don't have a corresponding active contact or active user record. |
| Users | Required. A collection of user records to get associated account and opportunity records for. |
| Value | The value of the Account Field to identify a partner account. Optional if
Partner Accounts is false. This input is captured in the Uses
Partner Accounts section of action properties in Flow Builder. |
Store Output Values
| Field | Description |
|---|---|
| Account | An account record that’s associated with one of the specified contacts or unmatched email addresses. |
| Opportunity | An opportunity record that’s associated with one of the specified contacts or the returned account record. If no opportunities are found, then it’s an opportunity record that’s owned by a user in the specified user collection. |
| Unmatched Email Addresses | A collection of email addresses that don't have a corresponding account or opportunity. |
Error Conditions
| Error Condition | Description |
|---|---|
| No Account Field | If Partner Accounts is Error Code: REQUIRED_FIELD_MISSING |
| No Comparison Operator | If Partner Accounts is Error Code: REQUIRED_FIELD_MISSING |
| No Value | If Partner Accounts is Error Code: REQUIRED_FIELD_MISSING |
Usage
To use this action, you must enable Sync Email as Salesforce Activity. The action is designed mainly to be used within the Activities: Match Email to Records flow.
How It Works
This action uses as input the date the email message was sent and user and contact records that match an email address in the From, To, or CC fields in the message. Optionally, input includes email addresses that don’t match a user or contact record. If you use partners in your sales process, the Partner Accounts, Account Field, Comparison Operator, and Value fields capture the criteria you use to indicate partner accounts.
The action queries the AccountId field in contact records to find the account that corresponds to contacts in action input.
If no accounts were found, the action checks the domain of the Website field value of an account. If that domain matches the email domain of any address in Unmatched Email Addresses in input, then the action picks that account. If multiple accounts were found, then the action picks the account that has the most recent LastActivityDate.
After finding account records, the action queries the ContactId field in OpportunityContactRole records to match contacts to an opportunity. Only open opportunities that were created in the last year are included. If no opportunities were found, the action queries the AccountId field in opportunity records to find an opportunity with an account that matches Account in action output.
Email addresses that don’t have a corresponding account or opportunity are stored in Unmatched Email Addresses in output.
Account Tiebreakers
If multiple accounts correspond to a contact’s email address, the action follows this logic.
The action checks the RecordTypeId field on each of the contacts’ accounts. The action queries the Name field in the RecordType object. If the Name isn’t a partner, then the action assumes that it’s a non-partner account. Similarly, if the Name is a partner, the action assumes that it’s a partner account. To determine the account, the action evaluates these rules in order.
- If contact records have a mix of partner and non-partner values for the Name field in the RecordType object, then the action picks the non-partner account. The action adds it to Account in action output.
- If the majority of contact records have the same account, then the action picks that account and adds it to Account in action output.
- If the prior rules didn’t result in an account added to output, then the action picks the account that has the most recent LastActivityDate. The action adds that account to Account in action output.
Opportunity Tiebreakers
If multiple opportunities correspond to an email address, the action follows this logic. Opportunities that have been closed for 60 days or more past the ActivityDate aren’t considered for matching.
- If an opportunity’s owner matches a user record in Users in action input, then the action picks that opportunity and adds it to Opportunity in action output.
- If an opportunity’s account owner matches a user record in Users in action input, then the action picks that opportunity and adds it to Opportunity in action output.
- If the prior rules didn’t result in an opportunity added to output, then the action picks the opportunity with the most recent LastActivityDate. The action adds that opportunity to Opportunity in action output.
Limitations
This action is limited to usage within a flow. It can't be invoked through other methods such as Apex, REST API, Copilot, Prompt Studio, or Einstein Bots. While actions can typically be invoked through various frameworks like InvocableActionService, this specific action is restricted solely to Flow.
If the activityId field is empty when debugging this action, use the Developer Console to query StagedEmail for a value.

