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
AsterAster 

Issue with FROM address in Email using triggers.

Hi,

 

I am trying to write a trigger that will send an Email to the associated contact on 'status' change. I have defined the email template in the My Templates

 

The problem I am facing is that, that the Email template does not provide an option to set the FROM Email Name and email address. Hence when the trigger fires, it sends the email using the system admin name and email id.

 

I want the email to be sent using the name 'CUSTOMER CARE' and using the email 'customercare@company.com'.

How to achieve this?

 

Secondly, which is the right way to store the templates, in My Templates or in Communication Templates -> Email Templates?

 

Thanks.

 

Ady

Best Answer chosen by Admin (Salesforce Developers) 
TrimbleAgTrimbleAg

Setup the Org wide e-mail address, and then you will be able to select it.

 

Go to setup

Administration setup

Email Administration

then select Organiozation wide addresses and setit up with your customer case address

 

Go back to the workflow and y7ou will be able to select that as the running e-mail address.

 

I have done this several times so I know it works.

 

PB

All Answers

TrimbleAgTrimbleAg

Do you not have workflows? This would be simple, also you cant create your e-mail as a org wide e-mail for the workflow.

 

PB

AsterAster

Hi,

 

Ofcourse. I had first tried to use workflows, however to set the FROM address, I can see only one option, i.e. Current User's email address. This would mean that the FROM address would change based on the loged in user.

 

I want to set the FROM display name and address as static, say for example, Customer Care (care@company.com).

 

After writing my first note, I started reading up and see that I can use

'mail.setSenderDisplayName('Salesforce Support');'  to set the display name, however I have not been successful in setting both Display Name and address.

 

Ady

TrimbleAgTrimbleAg

Setup the Org wide e-mail address, and then you will be able to select it.

 

Go to setup

Administration setup

Email Administration

then select Organiozation wide addresses and setit up with your customer case address

 

Go back to the workflow and y7ou will be able to select that as the running e-mail address.

 

I have done this several times so I know it works.

 

PB

This was selected as the best answer