As I attempt data migration from one Salesforce org to another, I am finding EmailMessage to be a very unnecessarily complicated object to understand. At one point I thought I understood that recent updates around "Enhanced Emails" made the EmailMessage object similar to an Activity which is why it appeared in the Activity Timeline.

After further review of the documentation (Exhibit A & Exhibit B), it appears that Salesforce creates a Task Activity (prefix 00T) for each Email generated through the interface. Unexpected, but makes sense, but the problem is this "Task" doesn't exist anywhere that I can verify. I can search it through the interface and it doesn't return through a SOQL query of the ID.

How am I to migrate these message? I have 34k that have a RelatedToId for an Account, Opportunity, or Quote, but then I have 28k that have no RelatedToId. Of those 28k null values, some of them have an ActivityId and some do not (the ones that do not appear to be internal System Account emails which I am less concerned with).

Can someone provide some detail around EmailMessage and the requirements around migrating records for this object?

Update Some more details I have uncovered. I had an Account with 2 EmailMessages in the Activity Timeline. I deleted one using the Dev Console, hoping that by only removing the EmailMessage the Task would remain and it would just link there. Unfortunately, it removed it all together... not that bad considering the Task and EmailMessage should be linked that probably makes the most sense.

That said, what I don't understand is why the second EmailMessage when queried, the ActivityId can not be seen, if I go to the 00T Id I get the following message

enter image description here

But after reinserting the EmailMessage I removed I can access it's 00T ActivityId without an issue. It's worth noting that there are lots of instances where these so-called related Tasks appear to not exist, they can't even be queried directly. I see no pattern to these "black-boxed" Tasks.

1 Answer 1


If the tasks are archived they are not available through the API. I was able to do an Export All. The. Update the tasks to a status that is not archived. Then the API’s could see them. Also I learned that the tasks are created for backwards compatibility but the true object is in EmailMessase. Still trying to figure things out but that is what I have leavened in the past day. Hope this is helpful to someone.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .