?
Solved

Failure sending consecutive emails from .NET web portal

Posted on 2011-09-14
2
Medium Priority
?
395 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 12

Expert Comment

by:viralypatel
ID: 36536183
0
 
LVL 70

Accepted Solution

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

Featured Post

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

Workplace bullying has increased with the use of email and social media. Retain evidence of this with email archiving to protect your employees.
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
To show how to create a transport rule in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Mail Flow >> Rules tab.:  To cr…
Suggested Courses

765 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