Loading

Override 'From' address with SingleEmailMessage

Julkaisupäivä: Oct 13, 2022
Kuvaus
How to setup/override in salesforce From address using SingleEmailMessage? 
Ratkaisu

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 
Knowledge-artikkelin numero

000386605

 
Ladataan
Salesforce Help | Article