0

Is it possible to assign FROM email address to an email going out from an APEX class. This email will be triggered by an insert operation.

Currently, which ever user(portal user) is performing this operation, email goes out with From address being user's email address.

Can I assign or mask from address so that portal user's account Email address is displayed in From email address for the recipients.

Thank you for your help!

2 Answers 2

2

You want the setSenderDisplayName() method: https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_email_outbound_base.htm#apex_Messaging_Email_setSenderDisplayName

This lets you spoof the from address when sending an email.

1
  • Thank you @John Westenhaver. I will try this out. I think this should do it. However just to make sure, we cannot explicitly set From email address correct?
    – Yash Mehta
    Commented Jan 27, 2015 at 19:06
0

Yash,

If you create an organization-wide email address, you can then specify that in the SingleEmailMessage.setOrgWideEmailAddressId() - http://sforce.co/1zxuEp6 - method and the outbound email will appear to be from the specified address rather than the user.

1
  • Thanks for the response. However in our case, emails going out are initiated by portal users belonging to different organizations. Using one generic email address will not work in this case. However, updating Email Name by their companie's name will serve the cause.
    – Yash Mehta
    Commented Feb 5, 2015 at 19:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .