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
Nikita Yadav 17Nikita Yadav 17 

Get Organization wide Address in Process builder to set parameter value of apex class

Hello ,

I have created process builder which calls apex class to send email notifications. This class method accepts some paramters and one of the parameter is FromAddress. I want to set FromAddress value from Organization wide address but I dont know how to access these address in Process builder. Please help me with this.

Thank u.
mukesh guptamukesh gupta
Hi Nikita,

Not feasible by process builder , you can follow below code
 
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();  
string body = 'Hi ';
String[] toAddresses = new String[] {'abc@gmail.com'}; 
mail.setToAddresses(toAddresses);
mail.setSubject('Test Subject');  
mail.setSaveAsActivity(false);  
for(OrgWideEmailAddress owa : [select id, Address, DisplayName from OrgWideEmailAddress]) 
{
 if(owa.Address.contains('testuser')) 
  mail.setOrgWideEmailAddressId(owa.id); 
}
mail.setHtmlBody(body);  
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });

if you need any assistanse, Please let me know!!

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh