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
PRepakaPRepaka 

SetReplyTo for visualforce email template

hi

 

Can u please tell me how to set SetReplyTo option for an Visualforce email template. by default it takes the User email id. but i want to change the reply to email address. how can i do this. please help me

crm_expertcrm_expert

In the controller:

 

 

Declare the object:

public Messaging.SingleEmailMessage mailHandler = new Messaging.SingleEmailMessage();

 

Setting the replyto:

mailHandler.setReplyTo('test@sumit.com');

 

 

 

Hope it helps,

 

~Sumit

Message Edited by crm_expert on 10-16-2009 12:06 AM
Rasmus MenckeRasmus Mencke

Here is an example in a visualforce email template:

 

 

<messaging:emailTemplate subject="test" replyTo="someone@acme.com" recipientType="contact" > <messaging:plainTextEmailBody > Congratulations! This is your new Visualforce Email Template. </messaging:plainTextEmailBody> <messaging:htmlEmailBody >fdsdf</messaging:htmlEmailBody> </messaging:emailTemplate>

 

 

 

kprkpr

Hi Rasmus,

 

This setting of replyTo attribute in emailTemplate tag isn't working for me, whatever be the email domain..i.e., gmail.com or yahoo.com or mycompany.com.

 

Is there any other setting we should be using to make it work? 

JeriMorrisJeriMorris
Did you find a solution to this? I'm having the same problem. Setting the replyTo attribute in the Visualforce email template doesn't seem to have any impact. Neither does using setReplyTo() via Apex.
kprkpr
Nope. I gave up after several attempts
StevevStevev

Guys, Not sure if this helps you  but one way is as follows:

 

Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setReplyTo('support@acme.com');

 

 

Which seemed to do the trick for me in my email class. However I haven't managed to generalize it using a string variable read from an object field:

 

 

String DONOTREPLY = Account.DoNotReplyEmail__c;
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setReplyTo(DONOTREPLY);

Hope this helps. (Sorry if you get a bunch of emails I had trouble pasting the code lines in).