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

Setting up of From address in Email.Urgent



We have an email messaging class Messaging.SingleEmailMessage for sending custom emailsWe need to configure the From email Address,and we are not able to find any such property that we can set the "From" address in Messaging.SingleEmailMessage object.



Kindly provide the solution as soon as possible!!






Have you tried these properties?


Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();


// Specify the name used as the display name.
mail.setSenderDisplayName('Salesforce Support');

Actually my requirement is that I need to assign the from address.Actually in my app the person who logs in gets an email when he logs in.The problem is that the email is getting sent to the Junk folder as the from and to address are the same.So is there any way to set the from address??
Well, I am pretty sure setting the ReplyTo is actually setting the "from". 

Hi Frodo,


 I have tried the same and well it does not set the from address.When I click on reply the reply address is set.The from address is still a problem.

Well, I am out of ideas.   I have been able to use the replyto method successfully before.  Perhaps if you post the code someone will be able to spot a problem.  Good Luck,  I hope you solve it soon.

In email the Reply-To and the From are not the same thing. By setting the Reply-To to something like that is where the email goes when someone hits reply.


What is being asked for here, and I need the same, is for the From address to also be configurable. Right now there appears to be no way to set this. SenderDisplay name is the friendly part of the From address and Reply only displays after someone hits reply.


For example


$singleEmail = new SingleEmailMessage();

$singleEmail->setSenderDisplayName("Friendly Service Center");



Will yield an email like this...


From: "Friendly Service Center" []


That will switch to this when reply is hit...




In my particular case I am using the Outbound Message triggered in a workflow, to invoke a SOAP service at on my side, to turn around and invoke sendEmail. The FROM address defaults to the account of the user credentials provided, or the account of the send-as-user on the Outbound Message if using the session id.


Any ideas on how to get around this?



Yeah, did this using a webservice!!!!Only way i cud find.
Thanks that is where I'm at with this. Outbound Message in a workflow, to my own web service, then sending from there. Even took the time to write out a utility to pull the email template, populate the {!Object.Field} tokens (merge) and send the email. A complete hack if you ask me from an otherwise sound product.