Solved

Failure sending consecutive emails from .NET web portal

Posted on 2011-09-14
2
337 Views
Last Modified: 2012-05-12
Hello everyone,

Windows Server 2008 R2 Enterprise
.NET 3.5
IIS 7.5

We are having an issue where in one of our ASPX pages, we send an email confirmation after the user clicks a button.  The first attempt is always successful, but on subsequent attempts within a short time span, the caught error is "Email Server: Failure sending mail.".  I have posted the function we use to send these emails below.

My questions are:
1)  is there something within the code that is causing the errors after the first attempt
2)  is there any log files, or logging that can be done to acquire more information regarding the failure (error message is not too helpful)
3)  is there possibly a better suited .NET class we can use to send these emails

Thanks in advance for any guidance,

Oliver

        Public Shared Sub SendGenericEmail(ByVal emailAddress As String, ByVal emailSubject As String, ByVal emailBody As String, _
                                           ByVal attachmentPath As String)

            Dim oSMTP As New System.Net.Mail.SmtpClient
            Dim replaceFields As New ListDictionary()
            Dim message As New MailDefinition()

            message.Subject = emailSubject
            message.IsBodyHtml = True

            Dim oMessage As New MailMessage()
            oMessage = message.CreateMailMessage(emailAddress, replaceFields, New LiteralControl())
            oMessage.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure
            oMessage.ReplyTo = New MailAddress(DTHClassLibrary.DTH.StaticVariables.ReplyToAddress)
            oMessage.Body = emailBody
            If attachmentPath <> String.Empty Then
                oMessage.Attachments.Add(New Attachment(attachmentPath))
            End If

            ' Send the message
            Try
                oSMTP.Send(oMessage)
            Catch ex As Exception
                Throw ex
            End Try

        End Sub

Open in new window

0
Comment
Question by:dthansen
2 Comments
 
LVL 12

Expert Comment

by:viralypatel
ID: 36536183
0
 
LVL 69

Accepted Solution

by:
Éric Moreau earned 500 total points
ID: 36536284
0

Featured Post

How does your email signature look on mobiles?

Do your employees use mobile devices to reply to emails? With mobile becoming increasingly important to the business world, it is in your best interest to make sure that your email signature looks great across all types of devices.

Join & Write a Comment

Microsoft has released various new features which are capable of handling various tasks. One of these tasks is ‘Migration from pop3 to Exchange Server’. Pop3 data stores various data along mailboxes like contacts, tasks, etc. So, it becomes the need…
Marketers need statistics and metrics like everybody else needs oxygen. In this article we explain how to enable marketing campaign statistics for Microsoft Exchange mail.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In this Micro Video tutorial you will learn the basics about Database Availability Groups and How to configure one using a live Exchange Server Environment. The video tutorial explains the basics of the Exchange server Database Availability grou…

706 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

19 Experts available now in Live!

Get 1:1 Help Now