Solved

Failure sending consecutive emails from .NET web portal

Posted on 2011-09-14
2
377 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 500 total points
ID: 36536284
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

New-MailboxSearch Powershell Command and step by step approach to Search and Extract Emails form Exchange 2013 Journaling server.
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
In this video we show how to create an Address List 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 Organization >> Ad…
The basic steps you have just learned will be implemented in this video. The basic steps are shown to configure an Exchange DAG in a live working Exchange Server Environment and manage the same (Exchange Server 2010 Software is used in a Windows Ser…

730 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