Solved

No difference with ASP.NET asynchronous email

Posted on 2013-05-23
2
339 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
ID: 39190487
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
ID: 39202013
Ok will do
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
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…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

856 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