function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
dwwrightdwwright 

Changing EmailMessage body before it sends

I've written a trigger which acts on the EmailMessage object, doing a string replace on a URL in the body to make it accessible to the recipient of the e-mail. The trigger runs before insert, and originally worked fine, as the email was sent into salesforce from an external e-mail, and then forwarded.

 

I'm running into an issue now with sending e-mails from within salesforce. The same trigger will change the values in the body before inserting into the database, but NOT before sending the e-mail. Since apparently e-mails are sent from Salesforce BEFORE insertion, I can't figure out how to make any changes to an EmailMessage before it is sent. Is anybody aware of a method of doing this?