I have enabled enhanced email in the org and I am trying to write a trigger to restrict email logging against certain objects using Outlook Add-In. However, I cannot find what determines an EmailMessage object created from outlook against an EmailMessage from a regular email such as Email2Case since users should be able to log in against Case as well. I looked at the emailMessage object reference and it does not say anything in the documentation about how the email was created.

In other words, is there a field in EmailMessage api that would help me determine the source of the email?

1 Answer 1


These may be of some assistance:

Option 1:

EmailMessage.CreatedById will be the User setup in Setup | Support Settings | Automated Case User

In every org I have worked on, the Automated Case User is a headless user (i.e. not associated to a real person) and such user would be unlikely to be using the Outlook Add-In

Option 2:

EmailMessage.ParentId is non null when created by Email-to-Case. EmailMessage.RelatedToId will be non-null for all other EmailMessage including Outlook Add-In. Use EmailMessage.Incoming = true to filter only inbound email messages

Option 3 (hypothesis, untested):

EmailMessage.Headers may contain text that distinguishes Outlook Add-In emails from all other EmailMessage.Incoming = true

You must log in to answer this question.

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