Solved

Failure sending consecutive emails from .NET web portal

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

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…
Local Continuous Replication is a cost effective and quick way of backing up Exchange server data. The following article describes the steps required to configure Local Continuous Replication. Also, the article tells you how to restore from a backup…
In this video we show how to create an email address policy 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…
To show how to generate a certificate request 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 Servers >> Certificates…

895 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

16 Experts available now in Live!

Get 1:1 Help Now