I’m using the new System.Net.Mail.MailMessage to send emails and will like to have a way to confirm if sent ok. (I have no problems sending, I just need the confirmation only)
< xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Which function or method to use Can anyone post a snippet for this
Thanks all

Does anyone know how to confirm if an email was sent successfully?
tjokiest
[
Flags] public enum DeliveryNotificationOptions {None = 0, OnSuccess = 1, OnFailure = 2, Delay = 4, Never = (
int)0x08000000}
please try the
DeliveryNotificationOptions property on the MailMessage
Makoto
Imports
System.NetImports
System.Net.MailModule
Module1 Sub Main() Dim msg As New MailMessage Dim client As New SmtpClient("smtpserver")msg.DeliveryNotificationOptions = DeliveryNotificationOptions.OnSuccess
msg.To.Add(
New MailAddress("x@y.com"))msg.From =
New MailAddress("x@y.com")msg.Subject =
"test"msg.Body =
"Test"client.UseDefaultCredentials =
True 'Optionalclient.Send(msg)
End SubEnd
ModuleRyanTF
What do you mean by this:
So set MailMessage.Deliver.... = Deliver...Success
Intellisense is not giving me any member of this type : MailMessage.Deliver
BethM
Mr-T
Its an enum
So set MailMessage.Deliver.... = Deliver...Success
redwyre
msg.DeliveryNotificationOptions = DeliveryNotificationOptions.OnSuccess
I paste this code in a module and could not get anything resembling "DeliveryNotificationOptions" in Intellisense after typing msg.
this is the code:
Imports System.Net
Imports
System.Net.MailModule
Module1 Sub Main() Dim msg As New MailMessage Dim client As New SmtpClient("smtpserver")msg.DeliveryNotificationOptions = DeliveryNotificationOptions.OnSuccess
'msg.To.Add(New MailAddr... End SubEnd
ModuleJeff Pigott
Could you try something for me reguarding the DeliveryNotificationOptions...
I've successfully been able to impliment the option and get a Delivery Receipt.
Though if I send more then one message I only get the Delivery receipt for the first message sent.
Any subsequent message does not get a delivery receipt.
The Connection to the SMTP Server stays connected even after the SMTPClient & MailMessage Objects go out of scope and a Manual Garbage Collections Happens. I'm guessing this is to allow multiple messages to be send without opening and closing the SMTP connection each time.
Though It seems that I only get the one Delivery Receipt for the Connected Session.
I ran a Protocol Trace and Noted the on the RCPT TO Command sent to the SMTP Server only had the NOTIFY=STATUS for the First message. All the others did not have it.
Could you Verify this I could send you my Test app if you like. I've included the Code of my SendEmail Function
Thanks,
Scott<-
Imports
System.Net.MailPublic
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) ThenccAddress =
New MailAddress(strCC, strCC)eMail.CC.Add(ccAddress)
End If If Not String.IsNullOrEmpty(strBCC) ThenbccAddress =
New MailAddress(strBCC, strBCC)eMail.Bcc.Add(bccAddress)
End If If Not String.IsNullOrEmpty(strTo) ThentoAddress =
New MailAddress(strTo, strTo)eMail.To.Add(toAddress)
ElseintStatus = -2
End If If Not String.IsNullOrEmpty(strFrom) Then If intStatus = 0 ThenfromAddress =
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 TheneMail.AlternateViews.Add(AlternateView.CreateAlternateViewFromString(strBody, htmlType))
ElseeMail.Body = strBody
End If Dim client As SmtpClient = New SmtpClient(tbSMTPServer.Text)client.Send(eMail)
client =
Nothing End If ElseintStatus = -1
End IfhtmlType =
NothingeMail.Dispose()
System.GC.Collect()
fSend_Email = intStatus
End Function
Private Sub Button3_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.ClickintEmailStatus = fSend_Email(tbFrom.Text, tbFrom.Text, tbTo.Text, tbCC.Text, tbBCC.Text, tbSubject.Text, rtbMessage.Text,
False, 14) End SubLisaF
Thanks again
brendon.smith
Sorry for the newbie question:
But how would you use these enums in VB2005 for setting a boolean variable to True if sent OK and false if otherwise
Thanks
Skippy1313
I belive this is added post Beta2.
So no wonder you are not seeing this in intellisense
Use the VS2005 RTM bits or just use the free redistributables and sdk.
TazInfo
Thanks for your patient.
Since I have not gotten the Visual Studio 2005 Proffessional version I ordered from Amazon I'm still using the Beta #2.
VS2005Simen
VS2005 8.0.50727.42 (RTM.050727-4200)
.NET Framework 2.0.50727
Thanks,
Scott<-
fcampanini
You don't need to wait.
The .NET 2.0 Redist (framework) and sdk are free :-)
and the SDK is also free. Download, and just set the path to the
VBC compiler and you are good to go. You can easily develop the apps
with just a good editor and fx/sdk
Try http://msdn.microsoft.com/net