SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have created a custom action through which I am sending the email to the selected contact items from the contacts list.

I have used SPUtility.SendEmail() method to send mail. To show other than central admin's email id to the receiver of the email I have set the from attribute of the Email header in the code like below,

if (currentItem != null)
    header = new StringDictionary();
    header.Add("to", Convert.ToString(currentItem[SPBuiltInFieldId.EMail]));
    header.Add("subject", emailSub);
    header.Add("content-type", "text/html");
    logMailTo += Convert.ToString(currentItem[SPBuiltInFieldId.EMail]) + ";";                                    
        header.Add("from", fromEmailAddresss); // here for example I have set that will be visible to the receiver of email.
    SPUtility.SendEmail(SPContext.Current.Web, header, emailBody);

There is scenario for example, I have set the outgoing email in the central admin is : and I have set the from attribute to, when user receives the email from and click on Reply from the outlook then "to" field in the outlook displays the

I want to set such a thing that when user replies to the email received from then it should display same email.

What should I do?

share|improve this question
up vote 2 down vote accepted

Have you tried adding a "replyto" header as well?

header.Add("replyto", fromEmailAddress);

It should make sure users get the correct address when they reply to the email.

If that does not work you might be out of luck with the SPUtility and have you use the "normal" C# way (you will need the address to your SMPT host):

System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
message.Subject = "The subject";
message.From = new System.Net.Mail.MailAddress("");
message.Body = "Tra la la";
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("Address to your SMPT server");
share|improve this answer
thanks for answering sir I tried your way but not working. it displays the email address of central admin instead header.add("replyto",fromEmailAddress); – users1100 May 7 '14 at 9:42
Even with both headers? In that case you should probably use the HttpUtility, since you are not using the SharePoint address anyway, will update my post – Robert Lindgren May 7 '14 at 9:46
Thanks a lot sir, it worked perfectly – users1100 May 7 '14 at 9:54

Your Answer


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.