Hi ok had this issue recently and want to see if anyone has a solution or work around, We use contact list in Excel to send emails to the group list
and this is the part of the code that handles the addresses, list limited to max 100 contacts with Gmail ( another problem for another day)
but what was happening was that even though testing and all worked well when sending to actual contact list it kept coming back saying " Email was not sent", and after an intense few days i found the issue was that when entering the email addresses someone had entered theirs as " joexxxx@:hotmail.com" note the colon ) after the @ symbol , stopped everything in its tracks.
I am assuming that this was down to Gmail and the email message was not sent because it has an invalid TO address.
and this is the part of the code that handles the addresses, list limited to max 100 contacts with Gmail ( another problem for another day)
but what was happening was that even though testing and all worked well when sending to actual contact list it kept coming back saying " Email was not sent", and after an intense few days i found the issue was that when entering the email addresses someone had entered theirs as " joexxxx@:hotmail.com" note the colon ) after the @ symbol , stopped everything in its tracks.
I am assuming that this was down to Gmail and the email message was not sent because it has an invalid TO address.
So question is is there something I can add to the code to inform me that one of the address is invalid or is there some other VBA to check that email adresses are correct, everything I have looked at basically checks to see if email addresses contain an @ or . nothing that checks for invalid character after the @.
Code below is part that handles the addresses
VBA Code:
For Each r In Sheets("Admin").Range("A9:A108") ''' range containing the distribution list
If Len(strAddressees) = 0 Then
strAddressees = r
Else
strAddressees = strAddressees & "; " & r
End If
Next
.To = strAddressees
.CC = ""
.BCC = ""
.From = """The Club"" <ThaMainClub@gmail.com>"
.Subject = "Results"
.HTMLBody = rangetohtml(r2)
.TextBody = "Hi all" & vbNewLine & vbNewLine & _
"Attached please find updated Results" & vbNewLine & vbNewLine & _
"Last updated " & Sheets("admin").Range("a2") & vbNewLine & vbNewLine & _
Sheets("Admin").Range("B4") & vbNewLine & _
Sheets("Admin").Range("B5")
.AddAttachment FileFullPath
On Error Resume Next
.Send
Application.Visible = True
If Err Then
MsgBox "E-mail was not sent", vbExclamation
Else
MsgBox "E-mail successfully sent", vbInformation
End If