Pages

Sunday, March 29, 2020

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:



28 comments:

  1. Hello,
    In the same way, do you know how to use in FLows the EAC Events ? I try to "Get Record" but I have an issue.
    Thank

    ReplyDelete
    Replies
    1. EAC data is not stored in SFDC, so I doubt you can get it from flow.

      Delete
  2. Is it possible to use a flow to create a task and copy over the relevant informaiton into a standard task when an email message is created?

    ReplyDelete
    Replies
    1. I see Email Message object is available on flow, so i think should be possible

      Delete
    2. I created the record in flow but now I need to show this record on activity History which is related to project object

      Delete
  3. I'm trying to investigate how to delete the tasks that gets created when an email is send from Salesforce. Any idea's how i could accomplish this?

    ReplyDelete
    Replies
    1. you may use Flow for this, checkout this video https://www.youtube.com/watch?v=TahU9V7W1Zg

      Delete
  4. How to share emails (incoming) to any specific queue.

    ReplyDelete
    Replies
    1. checkout this one https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_emailmessage.htm

      If IsPrivateDraft is set to true, then only the CreatedById user can view, update, and send this email draft. If IsPrivateDraft is set to false, then any user with permissions to work on the case can see these drafts. Once the email is sent (Email Status = Draft), then this field is updated to be false. Public drafts are loaded and visible in Salesforce Classic while Private Drafts are only used in Lightning Experience.

      Delete
  5. how to capture the email sent date on parent object? Thanks.

    ReplyDelete
    Replies
    1. Is this on custom object or Account with Contact/Opportunity?

      Delete
  6. HI Johan,

    I have tested this out (created an email on case ---> email message is created and also the related task.
    Then did an export of that email message and found the related task by the activityId. But noticed Indeed the "ISCLIENTMANAGED" = False, but i have a value in "MESSAGEIDENTIFIER" (it's not empty like in your example)
    Can you elaborate?

    (i have enhanced email enabled)

    ReplyDelete
    Replies
    1. check out this article https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_emailmessage.htm

      Delete
  7. Hi Johan,
    I am sending an email from Opportunity and creating an email message record for that. this is visible under Activities related list on Opportunity Detail page. But for other profile Users, this records is visible only to those who are the record owner not all that profile users.
    how to enable that email message record to other users of that profile ? Please suggest.

    ReplyDelete
    Replies
    1. What do you mean with "creating an email message record", is this custom?

      Delete
    2. Yes, When Email is sent via Trigger, I am creating email message record from there.

      Delete
    3. Make the object not as Master-Child detail relationship with Opportunity.

      Delete
  8. This comment has been removed by the author.

    ReplyDelete
  9. hi Johan,

    Is there a way to access EmailMessageId or TaskId inside my aura component after synching an email from outlook to salesforce?

    OR

    Is there a way to access Message Identifier of synched email which i can use to query EmailMessage object to get the exact record?

    Basically i want to know in my Aura component (enabled in outlook panel) what emailmessage or task is mapped to a given synched email from outlook to salesforce.

    ReplyDelete
    Replies
    1. apologized, I am not familiar with Aura component

      Delete
  10. Johan, hi!

    Is there any way to store Email Message in the referring case and the Opportunity Activities History at the same time, because there is only one sObject we could use in WhatId?

    Thanks.

    ReplyDelete
    Replies
    1. You are right, one task only have one WhatId, unless you want to clone the Task, which might be not ideal.

      Delete
  11. Hi, How can I control the sharing of records for EmailMessage? I did't find EmailMessage in OWD sharing setting.

    ReplyDelete
    Replies
    1. since the email is visible to a record, I think it should follow that record accessibility

      Delete
  12. Is it possible display emails from Emailmessage object that are sent from particular record of a custom object? Kindly help..

    ReplyDelete
  13. I am trying to create a flow which should create a follow up task record when an email message is sent. Is it possible using Activity id? Can you please help

    ReplyDelete
    Replies
    1. I don't see issue to use flow with Email Message object, and you should be able to get WhatId and WhoId from the ActivityId for follow-up task.

      Delete

Page-level ad