How to determine if e-mail was sent OK

  • Thread starter Thread starter Robert Dufour
  • Start date Start date
R

Robert Dufour

With system.web.mail in VS2003, doing some tests, using localhost from IIS
as server, I noticed that my code queues the messages OK, but when changing
sender addresses I see that the mail message ends up in the Bad folder. I
need to know when that happens since the e-mails are of critical importance.
How can I detect in my code, if an e-mail got queued but the actual
transmission from the server was unsuccessfull and how can I find what the
reason for the failure was?

Any help would be appreciated,

Bob
 
authenticate and avoid the problem entirely....1.1 and above

Private Sub Page_Load(sender As Object, e As System.EventArgs)
Dim mail As New MailMessage()
mail.To = "(e-mail address removed)"
mail.From = "(e-mail address removed)"
mail.Subject = "this is a test email."
mail.Body = "Some text goes here"
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate",
"1") 'basic authentication
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername",
"my_username_here") 'set your username here
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword",
"super_secret") 'set your password here
SmtpMail.SmtpServer = "mail.mycompany.com" 'your real server goes here
SmtpMail.Send(mail)
End Sub 'Page_Load
 
Thanks for code but I don't understand what Username and Password the code
refers to? Can you help me to understand.
 
The username and password used to access the email account for that mail
server.
 
I'm interested in your code but don't understand the
"http://schemas...." you have in it. This is what I've been using. Can
you explain the difference? Mine works. Just curious.

Dim msg As New System.Net.Mail.MailMessage
Dim smtp As New System.Net.Mail.SmtpClient
msg.From = New System.Net.Mail.MailAddress("cj@my_co.com")
msg.To.Add("Sally@my_co.com,Bob@his_co.com")
msg.Subject = "This is a test"
msg.Body = "This is only a test" & vbcrlf & "1 2 3"
smtp.Host = "smtp.my_co.com"
smtp.Port = 25
smtp.DeliveryMethod = Net.Mail.SmtpDeliveryMethod.Network
smtp.Credentials = New
System.Net.NetworkCredential("me@my_co.com", "my_pass")
smtp.Send(msg)
 
actually "me@my_co.com" should be "cj@my_co.com" just example names
anyway but the same address is used from msg.from and in the network
credential.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top