473,320 Members | 1,936 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

SMTPClinet - mailMessage.DeliveryNotificationOptions only works once per session?

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
Dec 1 '05 #1
0 1772

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Trond A. S. Andersen | last post by:
Hi, all! I'm trying to use the System.Web.Mail. "package" combinded with System.Web.Mail.SmtpMail in order to send MS Excel spreadsheets attached to mail messages. However, sending one single...
4
by: Mark Rae | last post by:
Hi, Can anyone please tell me if it's possible to pass a System.Web.Mail.MailMessage object to a ASP.NET Web Service? Maybe using XML Serialization / Deserialization? I've been asked to...
3
by: Phil Mc | last post by:
Hi has anyone come accross the problem.... with referance to System.Web.Mail.MailMessage and System.Web.Mail.SmtpMail THIS WORKS FINE mail=new MailMessage(); mail.From =...
5
by: martin | last post by:
Hi, I have created a class that is totally seperate from my web application. However this class is used extensivly by the web application for stuff like data access. I wish to add a function to...
0
by: Scott Townsend | last post by:
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...
8
by: tshad | last post by:
I have an Application_Error function in my Global.asax function that works fine until I try to access my Session variables. I am emailing the results to myself whenever I get an error and would...
1
by: Santosh | last post by:
Dear All i am writting a code sending mail with attachement. i am writting code for sending mail in one page and code for attaching a file in the next page. aftet attaching a file i am taking...
25
by: =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?= | last post by:
I tried: <sessionState timeout="1"> </sessionState> bounced IIS, and after 1 minute still had a session. ??? -- thanks - dave
2
by: ronchese | last post by:
Hello. I'm using System.Net.Mail.SmtpClient class to send e-mails. Actually, I'm breaking the recipients in lots of 10 emails for each e-mail I send, and sending it to a machine that has the...
4
by: SevDer | last post by:
Hi, I've done some coding in my web application however right now for an unknown reason my asp.net 2.0 site is not setting asp.net_sessionid cookie and as a result, I am losing the session data...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.