Reply-To header to the MailMessage in .Net framework 1.1

.Net framework 2.0 upper version already has supported ReplyTo property for MailMessage class. But how to set this header to your MailMessage in .Net 1.1, here is what i found, hope it useful for you ^^.

How do I add the Reply-To header to the MailMessage?

To add the Reply-To header to an email, you need to use the MailMessage.Headers property. For example:
mail.Headers.Add( "Reply-To", "alternate_email@mycompany.com")
The following code snippet demonstrates this technique.


[ C# ]
MailMessage mail = new MailMessage();
mail.To = "me@mycompany.com";
mail.From = "you@yourcompany.com";
mail.Subject = "this is a test email.";
mail.Body = "this is my test email body.";
mail.Headers.Add( "Reply-To", "alternate_email@mycompany.com" );
SmtpMail.SmtpServer = "localhost"; //your real server goes here
SmtpMail.Send( mail );

[ VB.NET ]
Dim mail As New MailMessage()
mail.To = "me@mycompany.com"
mail.From = "you@yourcompany.com"
mail.Subject = "this is a test email."
mail.Body = "this is my test email body."
mail.Headers.Add("Reply-To", "alternate_email@mycompany.com")
SmtpMail.SmtpServer = "localhost" 'your real server goes here
SmtpMail.Send(mail)

From www.systemwebmail.com FAQ

0 nhận xét:

 

Coding experience share Copyright © 2010 | Designed by Ipietoon for Free Blogger Template