Sending Asynchronous Mail
public void SendAsyncMail()
{
MailMessage mail = new MailMessage();
mail.From = new MailAddress("Enter from mail address");
mail.To.Add(new MailAddress("Enter to address #1"));
mail.To.Add(new MailAddress("Enter to address #2"));
mail.Subject = "Enter mail subject";
mail.Body = "Enter mail body";
SmtpClient smtpClient = new SmtpClient();
Object state = mail;
//event handler for asynchronous call
smtpClient.SendCompleted += new SendCompletedEventHandler(smtpClient_SendCompleted);
try
{
smtpClient.SendAsync(mail, state);
}
catch (Exception ex)
{
}
}
void smtpClient_SendCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
{
MailMessage mail = e.UserState as MailMessage;
if (!e.Cancelled && e.Error!=null)
{
message.Text = "Mail sent successfully";
}
}
Nimish Garg
Software Programmer
Indiamart Intermesh Limited, Noida
http://nimishgarg.blogspot.com
Revision number 1, Thursday, March 18, 2010 7:33:43 AM by nimish_soft
This is not the most up to date version of this article. The most recent version can be found here.
You must Login to comment.
|
Thu, Mar 18, 2010 10:57 AM
by cnranasinghe
|
it is better explain Asynchronous mail
|
|
Thu, Mar 18, 2010 1:49 PM
by bharat200
|
how to use password recovery control use password recovery mail pls provide a code
|