Solved

No difference with ASP.NET asynchronous email

Posted on 2013-05-23
2
335 Views
Last Modified: 2013-06-15
Hi, I was making some upgrades to my code for emails to be sent asynchronously however I notice there is no difference in the delay after the user click s the send button.

This is the normal code

  Dim mail As New MailMessage()
        mail.From = New MailAddress(Label9.Text)
        mail.To.Add(Label9.Text)

        'set the content
        mail.Subject = "Normal"

        mail.IsBodyHtml = True

        'send the message
        Dim smtp As New SmtpClient("smtpserver") '
        smtp.Send(mail)

Open in new window


This is the new asynchronous method;

 Dim mailMessage As New System.Net.Mail.MailMessage

        mailMessage.From = New MailAddress(Label9.Text)
        mailMessage.To.Add("itsupport@seabrookcrisps.com")

        mailMessage.Subject = "Async Email"

        mailMessage.IsBodyHtml = True
        mailMessage.Body = "Test"

        Dim smtpClient As New SmtpClient()
        Dim userState As Object = mailMessage

        'Attach event handler for async callback
        AddHandler smtpClient.SendCompleted, AddressOf SmtpClient_OnCompleted

        Try
            'Send the email asynchronously
            smtpClient.SendAsync(mailMessage, userState)
        Catch smtpEx As SmtpException
            'Error handling here
        Catch ex As Exception
            'Error handling here
        End Try

Open in new window


Any ideas?
0
Comment
Question by:takwirirar
2 Comments
 
LVL 29

Accepted Solution

by:
Kumaraswamy R earned 500 total points
Comment Utility
send a test email asynchronously, following the steps in the debug mode, and view the actual email received from the process

http://www.asp.net/web-forms/videos/how-do-i/how-do-i-send-email-asynchronously-with-aspnet
0
 
LVL 1

Author Comment

by:takwirirar
Comment Utility
Ok will do
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
This video discusses moving either the default database or any database to a new volume.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now