I am trying to loop through a database query and send emails to the email addresses I get from the query. Here is my piece of code.
do until rs.EOF
Set myMail = CreateObject("CDO.Message")
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="relay-hosting.secureserver.net"
myMail.Configuration.Fields.Update
myMail.Subject= subject
myMail.From="something@Something.Something"
myMail.To = rs("Email")
myMail.HTMLBody = strMessage & "Some Message"
myMail.Send
Set myMail = Nothing
rs.MoveNext
loop
I have searched and tried different solution without any luck. Following line of the code seems to have an issue, but i could not find what
myMail.To = rs("Email")
Before giving any answer or suggestion please keep in mind,
- This code works fine when I use any static email address in "TO" attribute of CDO Message object
- The query is giving accurate results
- I receive 500 Internal server error when i use dynamic email (email from the query) in the "TO" attribute of CDO Message object. I don't have the access to the IIS to enable detailed error messages.