hello fellow 🙂 i am having a trouble on how can i retry sending failed email recipients. i am trying to make an application in vbnet where i can send emails to multiple address.
some code snippet:
Dim SmtpServer As New SmtpClient()
SmtpServer.Credentials = New Net.NetworkCredential(xInformation(0), xInformation(1))
SmtpServer.Port = CInt(xInformation(2))
SmtpServer.Host = xInformation(3)
SmtpServer.EnableSsl = True
Dim mail As New MailMessage()
mail = New MailMessage
mail.From = New MailAddress(xInformation(4), "Display Name")
mail.CC.Add(xInformation(5)) ' i will make a loop here to add recipients
mail.Subject = xInformation(6)
mail.IsBodyHtml = True
mail.Body = xInformation(7)
SmtpServer.Send(mail)
question arises:
1.) if i have to send, for instance, email to 5 recipients, and only
3 emails have been successfully sent, how can i know the
failed email addresses?
2.) where is the failed email address stored?
3.) what exceptions are needed to trapped this error?
I don’t think you can catch these exceptions in your code, the emails that do not get sent you will want to check on the smtp server there should be a mail folder within inetpub
\\ServerName\c$\Inetpub\mailrootInside of this folder you should find a folder called: BadMail and Drop please look at the contents of these. Your VB code doesn’t have access to what a valid email address might be, only that it will try to send an smtp email message, if it fails then the SMTP application handles that.
Per your comment:
Convert any code from C# to vb.net: http://www.developerfusion.com/tools/convert/csharp-to-vb/