Tuesday, February 21, 2023

Salesforce: EmailMessage object


When Enhanced Email is enabled, Salesforce will create EmailMessage object. Emails sent from Salesforce are saved as Email Message records and Task records. There is a link from the Email Message record to a Task record, which is ActivityId field.

If you use the Outlook panel (and without enabling EAC), you can "Log Email" manually to Salesforce for email received and sent out. Both emails received and sent will be stored both as EmailMessage (prefix 02s) record and Task record (prefix 00T).

How to differentiate emails sent from Salesforce and manually logged from an email client?
You will not find any difference on the Task object, both Type and TaskSubType will populate with "Email". But there are some differences in the Email Message object. Check out this query:
SELECT Id, ActivityId, FromAddress, ToAddress, FromName, IsClientManaged, MessageIdentifier, Subject, TextBody FROM EmailMessage






Row 1,4,5 - email manual log from Outlook
Row 2,3 - email sent from Salesforce

As you can see, IsClientManaged and MessageIdentifier are different.

Note: using the legacy My Email to Salesforce service (BCC) will not create Email Message records, but only Task.


Email in Lightning activity component
All emails logged to Contact or Lead will be shown in the Lightning under the activity component.

For emails manually logged and sent from Salesforce, clicking the email will open the EmailMessage record, and you will be able to Reply All, Reply, or Forward the email from that panel. Hover mouse over the email will show the URL where it will be landed, for example, https://mydomain.lightning.force.com/lightning/r/02s2H00001BMfIgQAL/view








For email from BCC email services, clicking the email will open a Task record, there is no option to reply, reply all, or forward as the record is a task. Hover mouse over the email will show the URL where it will be landed, for example, https://mydomain.lightning.force.com/lightning/r/00T2H00007KIQvsUAH/view














For EAC email, clicking the email will open the email in that panel, you are also able to Reply All, Reply, or Forward the email from that panel. The system also shows if the email is shared with everyone or a group or not shared. Hovering the mouse over the email will not show any URL, click "View full email" will open the full email as an email stream.















Reference:

No comments:

Post a Comment

Understanding Wire vs Imperative Apex Method Calls in Salesforce Lightning Web Components (LWC)

Understanding Wire vs Imperative Apex Method Calls in Salesforce Lightning Web Components (LWC) Introduction: Salesforce Lightning Web ...