How to send mail with reply to

In this post I want to show How we can send mail with reply to option in .NET. I means, for example we sent auto mail to site user using no-reply@domain.com. But That user need you support, then mail content. So he will try to use reply option for that mail. once he/she click on reply button, it will add To: text with reply@domain.com here we can’t see same id(no-reply@domain.com). Or sometimes we need to set job to look reply mail by another person that time we can use this option.

I hope some of them knows about this already, I posted for this to help beginners.

First I am going to show screen shot about what I am going to doing in this.

I sent mail using myname@domain.com to user@userdomain.com. In this mail I set reply to mail option to replymail@domain.com.

Subject: This is for Demo

Body: This is just for demo about reply to mail option in C#

Once it is deliver, in that mail we can see like this  reply to option in the mail details. Once user click on the reply option. Then that mail ID is added in the To mail box. See in this

Sent mail with Reply To in c#.net
Send mail with reply to option in C#.net

This we can do in C#.net well, we can do it same in VB.net too. But here I added only C# code Please check that code.

//This below code using System.Web.Mail
void SendUsingWebMail()
{
System.Web.Mail.MailMessage msgMail = new System.Web.Mail.MailMessage();
msgMail.To = "user@userdomain.com";
msgMail.From = "myname@domain.com";
msgMail.Headers.Add("Reply-To", "replymail@domain.com");
msgMail.Subject = "This is for Demo";
msgMail.BodyFormat = System.Web.Mail.MailFormat.Text;
System.Web.Mail.SmtpMail.Send(msgMail);
}
//This below code using System.Net.Mail
void SendUsingNetMail()
{
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient();
System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage(myname@domain.com,   "user@userdomain.com");
msg.ReplyTo = new System.Net.Mail.MailAddress("replymail@domain.com");
msg.Subject = "This is for Demo";
msg.Body = "This is just for demo about reply to mail option in C#";
smtp.Send(msg);
}

Please note here both methods used to send mail only, I method I used Web.Mail and other one Net.Mail

SendUsingWebMail(); //This is using System.Web.Mail

SendUsingNetMail();  //This is using System.Net.Mail recommended.

Both are working I tested. I hope it will work for you too, Sure.

Tip:- Please add import System.Net.Mail or System.Web.Mail at top.

I hope this code is helpful for you. If is there any better Idea then this please share with me.

Enjoy while coding..!

Thanks,

Naga Harish Movva.