Just the Priority property, the Reply-To header is set via a property called
ReplyTo on the MailMessage object. Since the ReplyTo property is of type
MailAddress, it can be a simple email address, or it can include a friendly
display name.
The following example demonstrates setting the ReplyTo
property.
[ C# ]
static void SetTheReplyToHeader()
{
//create the mail message
MailMessage mail = new MailMessage();
//set the addresses
mail.From = new MailAddress("me@mycompany.com");
mail.To.Add("you@yourcompany.com");
//set the content
mail.Subject = "This is an email";
mail.Body = "this is the body content of the email.";
//specify the priority of the mail message
mail.ReplyTo = new MailAddress("SomeOtherAddress@mycompany.com");
//send the message
SmtpClient smtp = new SmtpClient("127.0.0.1");
smtp.Send(mail);
}
[ VB.NET ]
Sub SetTheReplyToHeader()
'create the mail message
Dim mail As New MailMessage()
'set the addresses
mail.From = New MailAddress("me@mycompany.com")
mail.To.Add("you@yourcompany.com")
'set the content
mail.Subject = "This is an email"
mail.Body = "this is the body content of the email."
'specify the priority of the mail message
mail.ReplyTo = New MailAddress("SomeOtherAddress@mycompany.com")
'send the message
Dim smtp As New SmtpClient("127.0.0.1")
smtp.Send(mail)
End Sub 'SetTheReplyToHeader