Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

Friends,

This issue is driving me nuts. Basically, I have an APEX trigger which is supposed to send out emails to customers when new records are available for them to look at.

Everything is working as expected. Except the sender name on the email which is the "From address"

I read the documentation and called these methods as follows:

    // Specify the address used when the recipients reply to the email.  

        mail.setReplyTo('testaccount@testOrg.com');

        // Specify the name used as the display name. 

        mail.setSenderDisplayName('Test Org Account Team');

But the "from address" still shows my email because the trigger is executed by my user.

When the reply button is clicked, the sender is populated to the email address set above. But I do not want my email to show up on the "From address".

Looks like Salesforce is defaulting this to the person who ran the trigger. How can I override this :( ?

Thanks.

share|improve this question

2 Answers 2

up vote 5 down vote accepted

The only way to modify the From line of a mail is by using the mail.setOrgWideEmailAddressId(ID) which requires the ID of an Organization-Wide Address record defined in Your Name | Setup | Email Administration | Organization-Wide Addresses

Org wide addresses let you specify both the Display Name and the Email Address in From line of your outgoing mails. Documentation

share|improve this answer
1  
Confirming that I've done this in the past and this is the only proper way of changing the from address on email sent from apex. –  ca_peterson Jan 4 '13 at 22:44
    
Thanks for the answer but unfortunately in my case this could not work since it was not feasible to change the org wide Email ID since the email we wanted to use in this case was related to a specific group and it would not make sense to use it for other applications. –  Richard N Jan 18 '13 at 17:08
    
I had another requirement and this time it was feasible to change the org wide address. Thanks. –  Richard N Jan 31 '13 at 16:57

One of the posts suggests that Under "Email Administration" setting one has to check both the checkboxes under the section "Email Security Compliance" . It works fine when one takes the above actions.

did you check if the above was selected ?

Also check out this post from Stackexchange where another user has the exact same question with a solution to the question

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.