Solved

Failure sending consecutive emails from .NET web portal

Posted on 2011-09-14
2
392 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Resolve Outlook connectivity issues after moving mailbox to new Exchange 2016 server
This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
In this video we show how to create a User Mailbox 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 Recipients >> Mailb…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

695 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