Showing posts with label Asynchronous. Show all posts
Showing posts with label Asynchronous. Show all posts

Sunday, July 22, 2012

Send Asynchronous Email in

Send Asynchronous Email in

when you are sending bulk email using then sending email using traditional parameter would be terribly time consuming as a result of we'll ought to expect the execution of smtp.send().but in Async methodology Email are going to be delivered in background and that we also can manage the output of email by Async handler.

Here i'm providing a code snippet to send email in Async manner.

using System.Web.Util;

     static void SendAsyncEmail()
            MailMessage cnetcode_mail = new MailMessage();            
            cnetcode_mail.From = new MailAddress("");
            cnetcode_mail.Subject = "your subject goes here";
            cnetcode_mail.Body = "Body content of the email.";
            //send the message
            SmtpClient smtp = new SmtpClient("Outgoing SMTP IP"); //Enter mail server address           
            object userState = cnetcode_mail;            
            smtp.SendCompleted += new SendCompletedEventHandler(SmtpClient_OnCompleted) 
            smtp.SendAsync( cnetcode_mail, userState );