Setting a 'from' address in SingleEmailMessage
|Knowledge Article Number||000232863|
I want to set a from address in a salesforce SingleEmailMessage, but cant see a way to do this, and there is no standard method in the documentation.
I want an email to be sent from doNotReply@blahblah.com, however, the email of the internal user editing the record (which triggers the email) is being sent as a from address. I want an address which is not specific to a User.
To do this you must first set up a dedicated email address by navigating to Setup -> Administration Setup -> Email Administration -> Organization-Wide Addresses menu.
If you want to avoid hard-coding an Id, after creating your Org-Wide Address you can query them: