IsClientManaged in Salesforce EmailMessage

IsClientManaged in Salesforce EmailMessage

If EmailMessage is created with IsClientManaged flag set to true, then the users can modify EmailMessage.ContentDocumentIds to link file attachments even though the Status of the EmailMessage is not set to Draft. To update EmailMessage.ContentDocumentIds, ContentDocumentLink records should be created.

IsClientManaged in Salesforce EmailMessage is used to automatically create task record when the EmailMessage record is created if Enhanced Email is enabled.

Sample Code:

String strHTMLBody = '<html><body><b>Hello from InfallibleTechie</b></body></html>';
EmailMessage objEmailMessage = new EmailMessage();
objEmailMessage.IsClientManaged = true;
objEmailMessage.status = '3';
objEmailMessage.fromName = 'Test Name';  
objEmailMessage.subject = 'Example Email';  
objEmailMessage.htmlBody = strHTMLBody;
objEmailMessage.RelatedToId = '0063t000013wBfmAAE';
insert objEmailMessage;

Output:

Leave a Reply