• Jeremy Leiser
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

Hi,

Is it possible to get the ID of the Organization Wide Address you want, to be chosen with a test on its display address ?

I would like not to put "hard code" ID.

 

I found some code somewhere and pasted it in mine, but it doesn't work :

 

// create a new single email message object  
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
	
// Assign the addresses for the To, CC and BCC lists to the mail object.  
email.setBccAddresses(lEmailAddressesList);

// Use Organization Wide Address  
for(OrgWideEmailAddress owa : [select id, Address from OrgWideEmailAddress]) {
if(owa.Address.contains('CSR')) email.setOrgWideEmailAddressId(owa.id); } 

// Specify the subject line for your email address.  
email.setSubject('The request has been closed : ' + closedRequest.Name);
	
// Set to True if you want to BCC yourself on the email.  
email.setBccSender(false);
	
// Optionally append the salesforce.com email signature to the email.  
// The email address of the user executing the Apex Code will be used.  
email.setUseSignature(false);

email.setHtmlBody('This request :<b> ' + closedRequest.Name +' </b>has been closed<br />' +
'Subject : ' + closedRequest.Subject__c +'<br />' +
'Short description : ' + closedRequest.Short_description__c +'<br />' +
'<p>Resolution :<b> ' + closedRequest.Answer__c +' </b></p>' +
'<p>Thank you</p>');

email.setSaveAsActivity(false);
  	
// Send the email you have created.  
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { email })

For now, I haven' find any documentation about this.

Does someone have any solution for me ?

Marie

 

  • March 23, 2011
  • Like
  • 0