Send mail from asp.net in background
<p>I am developing a website in which I need to send a mail to the client after he presses the submit button.But secondly I dont want the client to wait until the mail is sent and then he is advanced to the next page.
As soon as he presses the Submit Button,he should be redirected to next page,while in the background the mail is being sent.</p>

<p>I have tried sending mail Asynchronously.In the code below ,it sends the mail.When the operation completes it redirects the client to About.aspx.</p>

<pre><code>    MailMessage m = new MailMessage();
    MailAddress emailsender = new MailAddress(senderemail.Text, "User");
    m.From = emailsender;
    MailAddress recipient = new MailAddress(dest.Text);
    m.To.Add(recipient);
    m.Body = message.Text.ToString();
    m.Subject = subj.Text;
    SmtpClient client = new SmtpClient();
    //Add the Creddentials- use your own email id and password

    client.Credentials = new System.Net.NetworkCredential(senderemail.Text,password.Text);

    client.Port = 587; // Gmail works on this port
    client.Host = "smtp.gmail.com";
    client.EnableSsl = true; //This enables the SSL
    Object usertoken=m;
    client.SendCompleted += new SendCompletedEventHandler(client_SendCompleted);

    try
    {
        client.SendAsync(m, usertoken);
    }
    catch (Exception ex)
    {
        Exception ex2 = ex;
        string errorMessage = string.Empty;
        while (ex2 != null)
        {
            errorMessage += ex2.ToString();
            ex2 = ex2.InnerException;
        }
        HttpContext.Current.Response.Write(errorMessage);
    } // end try 
  void client_SendCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
{
    MailMessage mail = e.UserState as MailMessage;
    Response.Redirect("About.aspx");

    if (!e.Cancelled &amp;&amp; e.Error != null)
    {
        lblMessage.Text = "Mail sent successfully";
    }

}
</code></pre>
