I'm trying to send an email and get a delivery receipt back. I'm setting
the MailMessage.DeliveryNotificationOptions =
DeliveryNotificationOptions.OnSuccess and it works great for the First email
that is sent. Any emails after the first do not generate a Delivery Receipt.
I've tries Creating multiple MailMessages and SMTPClients, though even with
two of each DIMed I only get the one Delivery Receipt. If I set each Client
to a Different Server I get one for each Server, though any message sent
after do not get a Receipt.
I quit the Application and start it back up I get my token one receipt
again.
Am I missing something with the MailMessage.DeliveryNotificationOptions =
DeliveryNotificationOptions.OnSuccess setting?
I've included a copy of my Form below.
Any assistance would be appreciated.
Thanks,
Scott<-
--------------------------------------------
Public Class Form1
Dim bDebug As Boolean
Dim intEmailStatus As Integer
'----------------------------------------------------
' Function : fSend_Email()
' Returns: Integer
' -1 - No From Address
' -2 - No To Address
'----------------------------------------------------
Protected Function fSend_Email(ByVal strFrom As String, ByVal
strFrom_Name As String, ByVal strTo As String, ByVal strCC As String, ByVal
strBCC As String, ByVal strSubject As String, ByVal strBody As String, ByVal
bIsHTML As Boolean, ByVal iDelivery_Receipt As Int16) As Integer
Dim intStatus As Integer = 0
Dim toAddress, fromAddress, ccAddress, bccAddress As MailAddress
Dim eMail As MailMessage = New MailMessage()
Dim htmlType As System.Net.Mime.ContentType = New
System.Net.Mime.ContentType("text/html")
If Not String.IsNullOrEmpty(strCC) Then
ccAddress = New MailAddress(strCC, strCC)
eMail.CC.Add(ccAddress)
End If
If Not String.IsNullOrEmpty(strBCC) Then
bccAddress = New MailAddress(strBCC, strBCC)
eMail.Bcc.Add(bccAddress)
End If
If Not String.IsNullOrEmpty(strTo) Then
toAddress = New MailAddress(strTo, strTo)
eMail.To.Add(toAddress)
Else
intStatus = -2
End If
If Not String.IsNullOrEmpty(strFrom) Then
If intStatus = 0 Then
fromAddress = New MailAddress(strFrom, strFrom_Name)
eMail.From = fromAddress
eMail.Subject = strSubject
eMail.DeliveryNotificationOptions =
DeliveryNotificationOptions.OnSuccess
'eMail.Headers.Add("Disposition-Notification-To", """" &
strFrom_Name & """ <" & strFrom & ">")
If bIsHTML Then
eMail.AlternateViews.Add(AlternateView.CreateAlter nateViewFromString(strBody,
htmlType))
Else
eMail.Body = strBody
End If
Dim client As SmtpClient = New SmtpClient(tbSMTPServer.Text)
client.Send(eMail)
client = Nothing
End If
Else
intStatus = -1
End If
htmlType = Nothing
eMail.Dispose()
System.GC.Collect()
fSend_Email = intStatus
End Function
End Class