You need to sign in to do that
Don't have an account?

When does salesforce creates records of EmailMessage object? E.g. Email Alert, Single/Mass Email Message (Apex), Send Email (Standard button on Activities?
Hello there,
I am implementing a custom inbox functionality for community users in my project. I know I can track all outgoing emails from Salesforce using the object EmailMessage. However, I am still not clear in what cases, Salesforce creates EmailMessage records? E.g. Send an Email (standard functionality), Single/Mass Email Message (Apex), etc.
Thanks in advance.
I am implementing a custom inbox functionality for community users in my project. I know I can track all outgoing emails from Salesforce using the object EmailMessage. However, I am still not clear in what cases, Salesforce creates EmailMessage records? E.g. Send an Email (standard functionality), Single/Mass Email Message (Apex), etc.
Thanks in advance.
Please refer the below code for reference.
VisualForce:
Apex Code:
I hope it will be helpful.
Please mark it as best answer if the above information is informative.
BestRegards
RahulKumar
Thanks for the code snippets. However, that is not what I am currently looking out for.
This is what my observations regarding email messages.
- Emails sent through Email Alerts or System Emails ( reset password, new user registration) are not logged using EmailMessage object records. This is because these messages are not logged as Acivities associated with related Standard or Custom objects
- Only those EmailMessage records are created and preserved which are associated to either Standard or Custom Objects using the field Related To. Such EmailMessages need to be logged as they appear in ActivityHistory records related list under detail pages of those object records
Please, let me know if my understandings are incorrect.Thanks.