Loading

Override 'From' address with SingleEmailMessage

Data pubblicazione: Oct 13, 2022
Descrizione
How to setup/override in salesforce From address using SingleEmailMessage? 
Risoluzione

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 
Numero articolo Knowledge

000386605

 
Caricamento
Salesforce Help | Article