Solved

No difference with ASP.NET asynchronous email

Posted on 2013-05-23
2
336 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

863 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

25 Experts available now in Live!

Get 1:1 Help Now