Trying to send mail with CDOSYS, I get the following error, error '8004020f'
Issue DetailsOur variables are created for their associated form fields. So we have to make sure that when we reuse variables, we either "copy and paste" them. Or, if we are working on another page where the variables are stored. We need to make sure we spell them correctly, or we will encounter the following error.
CDO.Message.1 error '8004020f' The server rejected one or more recipient addresses. /yourpage.asp, line 42
Recreate Issue
[Classic ASP - CDOSYS Email Script with misspelled email Variable]
Set myMail = CreateObject("CDO.Message")
'This section provides the configuration information for the remote SMTP server.
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'Send the message using the network (SMTP over the network).
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = 192.168.2.8myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False 'Use SSL for the connection (True or False)
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic (clear-text) authentication
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") =sendusername
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") =sendpassword
myMail.Configuration.Fields.Update'End remote SMTP server configuration section==
myMail.To = recieverusername
myMail.Subject = "this is the subject"myMail.From = sendusername
myMail.TextBody = "this is the body"myMail.SendSet myMail = Nothing
In the above myMail.To
Copy
Search Site
Search Google
, line. We have "recieverusername"; however, the variable is misspelled (receiver, not reciever). So, it is not finding the email address associated with the variable.
Resolve Issueto resolve this issue.
Make sure all your variables are spelled correctly and associated with the proper form field for the mail to send. In the above issue, we see that the word "reciever" is incorrectly spelled, so to the CDOSYS component cannot find an email address to connect to the variable. Correctly spelling the word will resolve this issue. "receiverusername"