Im having a problem and hoping that you would be able to help me. Im wanting to send email using system.net.mail but I need to be able to have any bounced emails sent to a central address
Im having a problem and hoping that you would be able to help me. Im wanting to send email using system.net.mail but I need to be able to have any bounced emails sent to a central address
Dim MyEmailClient As New SmtpClient
MyEmailClient.Host = "111.111.111.111" ' This is my Set to my IP Address
Dim MyEmailMessage As New MailMessage()
MyEmailMessage.From = New System.Net.Mail.MailAddress("SomeSentFromAddress@MyDomain.com")
MyEmailMessage.To.Add(New System.Net.Mail.MailAddress("SomeFakeAddress@MyDomain.com"))
MyEmailMessage.Subject = "Some Subject"
MyEmailMessage.Body = "Some Body Text"
MyEmailMessage.Priority = MailPriority.Normal
MyEmailMessage.Headers.Add("Return-Path", "BounceBack@MyDomain.com")
MyEmailClient.Send(MyEmailMessage)
I can't find a good example of DeliveryNotificationOptions functionaily.
I basicly want the bounceback email to be sent to an email of my choosing.
Dim MyEmailClient As New SmtpClient
MyEmailClient.Host = "111.111.111.111" ' This is my Set to my IP Address
Dim MyEmailMessage As New MailMessage()
MyEmailMessage.From = New System.Net.Mail.MailAddress("SomeSentFromAddress@MyDomain.com")
MyEmailMessage.To.Add(New System.Net.Mail.MailAddress("SomeFakeAddress@MyDomain.com"))
MyEmailMessage.Subject = "Some Subject"
MyEmailMessage.Body = "Some Body Text"
MyEmailMessage.Priority = MailPriority.Normal
MyEmailMessage.Headers.Add("Return-Path", "BounceBack@MyDomain.com")
MyEmailClient.Send(MyEmailMessage)
I can't find a good example of DeliveryNotificationOptions functionaily.
I basicly want the bounceback email to be sent to an email of my choosing.
Ez416
Participant
1088 Points
607 Posts
Re: HOW TO: Send email using System.Net.Mail
Sep 19, 2006 03:42 AM|LINK
StrongTypes
All-Star
30801 Points
6013 Posts
ASPInsiders
Re: HOW TO: Send email using System.Net.Mail
Sep 19, 2006 03:46 AM|LINK
[quote user="Ez416"]it says that MailMessage & DeliveryNotification are not define....what am i going to import(reference)?
You have to import System.Net.Mail. Also, it's DeliveryNotificationOptions, not DeliveryNotification.
Ez416
Participant
1088 Points
607 Posts
Re: HOW TO: Send email using System.Net.Mail
Sep 19, 2006 06:41 AM|LINK
So is this correct?
Dim SmtpClient As New System.Net.Mail.SmtpClient
Dim mailMessage As New MailMessage
SmtpClient.Host = "100.404.0.30"
SmtpClient.Port = 21
SmtpClient.Send("from@test.com", to@test.com, "Attn: sample title", "Body")
mailMessage.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure
What message will it send, if it fails to be delivered?
StrongTypes
All-Star
30801 Points
6013 Posts
ASPInsiders
Re: HOW TO: Send email using System.Net.Mail
Sep 19, 2006 12:32 PM|LINK
So is this correct?
Dim SmtpClient As New System.Net.Mail.SmtpClient
Dim mailMessage As New MailMessage
SmtpClient.Host = "100.404.0.30"
SmtpClient.Port = 21
SmtpClient.Send("from@test.com", to@test.com, "Attn: sample title", "Body")
mailMessage.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure
What message will it send, if it fails to be delivered?
You should be using the MailMessage object to compose the message and then send it using SmtpClient.Send(MailMessage). Per MSDN:
Ez416
Participant
1088 Points
607 Posts
Re: HOW TO: Send email using System.Net.Mail
Sep 20, 2006 05:42 AM|LINK
Bow99
Member
334 Points
86 Posts
Re: HOW TO: Send email using System.Net.Mail
Sep 20, 2006 11:23 AM|LINK
Hi there
Im having a problem and hoping that you would be able to help me. Im wanting to send email using system.net.mail but I need to be able to have any bounced emails sent to a central address
I initially thought that i just needed to add
MyEmailMessage.Headers.Add("Return-Path", ReturnAddresses@domain.com)
but this doesnt seem to be working as the bounce emails are not being sent to the ReturnAddresses@domain.com
It actually sent the bounced email to the email in the MyEmailMessage.To but I need it sending to ReturnAddresses@domain.com
Any help appreciated
StrongTypes
All-Star
30801 Points
6013 Posts
ASPInsiders
Re: HOW TO: Send email using System.Net.Mail
Sep 20, 2006 02:08 PM|LINK
[quote user="Ez416"]base on my code above...why does it not notify me that the message was not sent?....i've put up a fake FROM Email Address...
Have you modified your code as I've suggested? What does it look like now?
StrongTypes
All-Star
30801 Points
6013 Posts
ASPInsiders
Re: HOW TO: Send email using System.Net.Mail
Sep 20, 2006 02:09 PM|LINK
Hi there
Im having a problem and hoping that you would be able to help me. Im wanting to send email using system.net.mail but I need to be able to have any bounced emails sent to a central address
I initially thought that i just needed to add
MyEmailMessage.Headers.Add("Return-Path", ReturnAddresses@domain.com)
but this doesnt seem to be working as the bounce emails are not being sent to the ReturnAddresses@domain.com
It actually sent the bounced email to the email in the MyEmailMessage.To but I need it sending to ReturnAddresses@domain.com
Any help appreciated
As suggested on the previous page, see the DeliveryNotificationOptions enum.
Bow99
Member
334 Points
86 Posts
Re: HOW TO: Send email using System.Net.Mail
Sep 20, 2006 02:51 PM|LINK
Sorry that was a bit abstract
here is the code I used:
Dim MyEmailClient As New SmtpClient MyEmailClient.Host = "111.111.111.111" ' This is my Set to my IP Address Dim MyEmailMessage As New MailMessage() MyEmailMessage.From = New System.Net.Mail.MailAddress("SomeSentFromAddress@MyDomain.com") MyEmailMessage.To.Add(New System.Net.Mail.MailAddress("SomeFakeAddress@MyDomain.com")) MyEmailMessage.Subject = "Some Subject" MyEmailMessage.Body = "Some Body Text" MyEmailMessage.Priority = MailPriority.Normal MyEmailMessage.Headers.Add("Return-Path", "BounceBack@MyDomain.com") MyEmailClient.Send(MyEmailMessage)I can't find a good example of DeliveryNotificationOptions functionaily.
I basicly want the bounceback email to be sent to an email of my choosing.
Thanks
StrongTypes
All-Star
30801 Points
6013 Posts
ASPInsiders
Re: HOW TO: Send email using System.Net.Mail
Sep 20, 2006 02:59 PM|LINK
Sorry that was a bit abstract
here is the code I used:
Dim MyEmailClient As New SmtpClient MyEmailClient.Host = "111.111.111.111" ' This is my Set to my IP Address Dim MyEmailMessage As New MailMessage() MyEmailMessage.From = New System.Net.Mail.MailAddress("SomeSentFromAddress@MyDomain.com") MyEmailMessage.To.Add(New System.Net.Mail.MailAddress("SomeFakeAddress@MyDomain.com")) MyEmailMessage.Subject = "Some Subject" MyEmailMessage.Body = "Some Body Text" MyEmailMessage.Priority = MailPriority.Normal MyEmailMessage.Headers.Add("Return-Path", "BounceBack@MyDomain.com") MyEmailClient.Send(MyEmailMessage)I can't find a good example of DeliveryNotificationOptions functionaily.
I basicly want the bounceback email to be sent to an email of my choosing.
Thanks
Here's one example using your code:
MyEmailMessage.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure