Loading

Override 'From' address with SingleEmailMessage

Veröffentlichungsdatum: Oct 13, 2022
Beschreibung
How to setup/override in salesforce From address using SingleEmailMessage? 
Lösung

You can use the setOrgWideEmailAddressId(ID) instance method of SingleEmailMessage. To do this, first you have to setup your org wide default email address by going to Setup | Email | Organization-Wide Addresses. You can then get the ID of that email address and use that in the instance method.

OrgWideEmailAddress[] owea = [select Id from OrgWideEmailAddress where Address = 'example@example.com'];
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
if ( owea.size() > 0 ) {
    mail.setOrgWideEmailAddressId(owea.get(0).Id);
}
Reference: SingleEmailMessage methods 
Nummer des Knowledge-Artikels

000386605

 
Laden
Salesforce Help | Article