manikandan
New member
- Joined
- Mar 13, 2012
- Messages
- 2
- Programming Experience
- 3-5
Hi All,
I am having vb.net code for sending the email. Tmail his works fine. If the mail is not sent, i have to get delivery status in code.
I have tried delivery notification, it gives notification via mail only. But i want to check the status of the mail send in code immediately after send the mail.
Can anyone pls help me to sort out this issue.
Here is my sample.
Try Dim SmtpServer As New SmtpClient()
Dim mail As New MailMessage()
SmtpServer.Credentials = New _
Net.NetworkCredential("abcd@gmail.com", "1234")
SmtpServer.Port = 587
SmtpServer.EnableSsl = True
SmtpServer.Host = "smtp.gmail.com"
mail = New MailMessage()
mail.From = New MailAddress("abcd@gmail.com", "ABCD")
mail.To.Add("abcd@gmail.com")
mail.Subject = Subject.Text.ToString()
mail.Body = Body.Text.ToString()
mail.Priority = MailPriority.High
mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnSuccess
SmtpServer.Send(mail)
MsgBox("Mail Sent!!")
Catch ex As Exception
MsgBox(ex.ToString)
End Try
I am having vb.net code for sending the email. Tmail his works fine. If the mail is not sent, i have to get delivery status in code.
I have tried delivery notification, it gives notification via mail only. But i want to check the status of the mail send in code immediately after send the mail.
Can anyone pls help me to sort out this issue.
Here is my sample.
Try Dim SmtpServer As New SmtpClient()
Dim mail As New MailMessage()
SmtpServer.Credentials = New _
Net.NetworkCredential("abcd@gmail.com", "1234")
SmtpServer.Port = 587
SmtpServer.EnableSsl = True
SmtpServer.Host = "smtp.gmail.com"
mail = New MailMessage()
mail.From = New MailAddress("abcd@gmail.com", "ABCD")
mail.To.Add("abcd@gmail.com")
mail.Subject = Subject.Text.ToString()
mail.Body = Body.Text.ToString()
mail.Priority = MailPriority.High
mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnSuccess
SmtpServer.Send(mail)
MsgBox("Mail Sent!!")
Catch ex As Exception
MsgBox(ex.ToString)
End Try