I am an new subscriber and had seen a post for something similar to the problem I am having but not exactly that referenced this forum. Please forgive any newb mistakes in my first post

I am using CDO to send emails which all works fine EXCEPT when I have an invalid email address. I create a string array for multiple email recipients and use that string in the TO: field. If one or more of the addresses in the string is invalid then the code crashes and the email is not sent.

The invalid addresses are not like someone had formatted his/her email address incorrectly like omitting the @ sign, for example. It is more of having a typo, like John.Smth@gmail.com for John.Smith@gmail.com. Since John.Smth@gmail.com is not a valid email address then the code fails. Does anyone know of a way to check for the validity of each email and removing those from the string array BEFORE I send it?

I can loop thru the array and send an email one by one to the valid ones and have the code resume next when an email is attempted to be send to an invalid email address but I prefer not to do that.

Here is the code.


Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")

iConf.Load -1 ' CDO Source Defaults
Set Flds = iConf.Fields
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
' .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") _
' = "smtp.charter.net" 'Fill in your SMTP server here"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = Email_Provider 'Fill in your SMTP server here"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
End With

With iMsg
Set .Configuration = iConf
.To = Recipient_Email_Addresses
.CC = CC_Person
.BCC = ""
.From = Email_Sender '"""Some Guy"" <someguy@gmail.com>"
.Subject = Email_Subj
.TextBody = Email_Body
.AddAttachment Attachments 'or .AddAttachment Attachments(N) for more than one file - in array
End With