If you are sending a custom email on force.com site using apex on a feature like forgot password or username, one of the challenges is to change the display name of the email. Even though apex has a setdisplayname method , it will not work on the guest users as salesforce always appends the site creator username name on the emails which is a pain.
a. If you need to send a custom email on apex for guest users, create a organziation wide email address and create an email id which should be accessible on all profiles.
b. Now on the apex code, query from organization address and set the organizationaddress id on the email object. Now all the emails would come up the display name used on the organization address.
if(lstOrgWideEmailId.size() == 0)
throw(new PkException('There is no Organization wide email address setup in the org. Please set the organization wide email address'));
orgWideEmailAddressID = lstOrgWideEmailId.id;
Messaging.Singleemailmessage email = new Messaging.Singleemailmessage();
Subscribe to our mailing list and get tips to maximize salesforce to your email inbox.
I am honored to have your subscription. Stay tuned for tips to maximize your salesforce investment
Something went wrong.