Error sending out email with CDO.Message

skbohler
skbohler used Ask the Experts™
on
Our ASP VBscript programs that send out an email (like from a contact form) have worked perfectly for years. Suddenly, the .Send function is generating an error 80040211.

Again, nothing to our knowledge has changed.

Is there a way to see what the specific error may be?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
I assume you are using the IIS SMTP service to send emails through. Try to restart it.

BTW, I'd recommend to use the pickup service instead of TCP/IP connection to the SMTP service. So you could visually inspect the formed email and try to analyze what's wrong with it. It could bee too beg (bigger that the server's limit) or exceeds some other limitations.

Author

Commented:
Well, I am using CDO.Message and sending it through a remote Exchange server on port 25.

I just restarted the IIS SMTP service anyway, but it didn't remedy the situation.
Well, if CDO does not use the IIS SMTP, it surely does not make sense to restart it.
I'd suggest to setup the IIS SMTP to use your exchange as a smarthost and configure your CDO script to place the emails to the service's pickup folder.
If something wrong with the network connection or some other reason, the emails will be accumulated in the pickup folder or in the queue folder and you would be able to temporary stop the IIS SMTP service and then investigate what's actually wrong without having an error in your CDO-using app.

Did you check the size of the message you were sending, did it exceeded the exchange's limitation on a message size?
Build an E-Commerce Site with Angular 5

Learn how to build an E-Commerce site with Angular 5, a JavaScript framework used by developers to build web, desktop, and mobile applications.

Scott FellDeveloper & EE Moderator
Fellow 2018
Most Valuable Expert 2013

Commented:
Is the message that is sent always the same?  
Is it happening on every form submission or just some?
If some, can you tell what the difference is?
What is your SMTP provider?  Did two factor auth get turned on?
Perhaps port 25 was blocked. Can you use an alternative port?

Author

Commented:
Scott,

Thanks for your reply.

The message is slightly different in each one.
It happens on every form submission.
SMTP provider server is east.EXCH032.serverdata.net
I'm checking to see if port 25 is blocked. But it does seem to work if telnet to the server and open port 25.
I'd still suggest to configure the CDO to save to a file instead of sending and visually inspect the message's headers and body. It might be too big, or something else is wrong.

Author

Commented:
zc2,

Not sure how to do that, unfortunately.

Steve
just set any folder to the ""http://schemas.microsoft.com/cdo/configuration/nntpserverpickupdirectory" configuration variable and comment out the line which sets the "http://schemas.microsoft.com/cdo/configuration/smtpserver" variable.
Sorry, wrong property. Use "http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory"
put it a path to an existing folder, not to a file.

Also, the "http://schemas.microsoft.com/cdo/configuration/sendusing" need to be changed.

Author

Commented:
OK, made the edits. Still nothing in the folder though. Am I missing a step?
Just tried, a file was created in my "D:\temp\"
    With cdoConfig.Fields
          .Item(cdoURL & "sendusing") = 1  ' <-- this switches from TCP/IP mode to the pickup mode
      '    .Item(cdoURL & "smtpserver") = "east.xxx.xxx.net"
            .Item(cdoURL & "smtpserverpickupdirectory")="d:\temp\"
            .Item(cdoURL & "smtpserverport") = 25
            .Item(cdoURL & "smtpauthenticate") = 1
            .Item(cdoURL & "sendusername") = "dummyaccount@xxxxx.com"
            .Item(cdoURL & "sendpassword") = "xxxxxxxxx"
            .Item(cdoURL & "smtpusessl") = 1
          .Item(cdoURL & "smtpconnectiontimeout") = 60
          .Update
    End With

Open in new window

Author

Commented:
OK, I've got that working.

What should I do with the files it is creating?
First check the file size. Is it greater than the exchange's limit? Then open in a text editor and look for long not wrapped lines.
To send them further to the recipient move them to the IIS SMTP's pickup folder. Usually it's C:\inetpub\mailroot\pickup\

Author

Commented:
No, they're small and typical of the ones that go out fine. I moved them over to the IIS SMTP pick up folder and they went out fine.

Is there a way to have them put into the correct pickup directory so they're processed by the local smtp server and not our remote Exchange server? Is there a problem with doing it that way (since it seems that the local smtp server is not having a problem with it)?
Just put the correct folder to that CDO config property:
.Item(cdoURL & "smtpserverpickupdirectory")="C:\inetpub\mailroot\pickup\"

Open in new window

Is there a problem with doing it that way
As I said earlier, that's a way I would recommend. I use that approach in all my projects, no issues so far.

Author

Commented:
If I use that directory, I get an Access Denied error in my code.
Just give to the directory proper writing permissions to the user/group your process is running as/belongs to.
For an example, if your ASP's application pool working as "Application pool identity", you could grant a modifying permission to the whole IIS_IUSRS group:
icacls C:\inetpub\mailroot\pickup /grant IIS_IUSRS:M

Open in new window

Author

Commented:
OK, it's at the point where it writes to the pickup folder and then the file disappears. But, I'm not receiving the emails in my inbox (the test emails are to go to me). Hmmmmm

Author

Commented:
It seems it allows emails to go out when from one domain, but not another. Is there a place where I can control that?
Check, are those were not delivered stuck in the Queue folder (C:\inetpub\mailroot\Queue) or discarded as badmail and placed to C:\inetpub\mailroot\Badmail
Make sure that the SMTP service has the logging enabled and all the logging fields are included, then check the SMTP log files, it could have a clue what is wrong.

Author

Commented:
Thanks.

Turned out the emails sent from one address were being flagged as spam by my email provider.

Where do I set logging?
Launch Administrative Tools/Internet Information Services (IIS) 6.0 Manager
Open the properties dialog for your SMTP virtual server
Make sure the checkbox "Enable logging" is checked
Click "Properties"
Note the Log file directory
Switch to the Advanced tab
Make all the checkboxes checked.

Author

Commented:
Ok, I’ll try that.

Is it possible to relay email from the smtp server over to our remote exchange server?
Yes, on the "Delivery" tab click "Advanced…" and specify your exchange address as the Smart host, click OK, then "Outbound Security…" and specify our Exchange credentials here.
Scott FellDeveloper & EE Moderator
Fellow 2018
Most Valuable Expert 2013

Commented:
Turned out the emails sent from one address were being flagged as spam by my email provider.
If these are only ever going to you, it will be fine.  If you are going to be sending anything to clients/visitor using CDO you will really be better off using a 3rd party smtp service like sendgrid to increase deliverable rates.

Author

Commented:
Thanks so much!!!

Author

Commented:
I'm running into emails now in the Badmail folder since adding a smart host. Do you know how I can remove that? If I just clear out the field, the OK button becomes inactive.
Try to analyze the SMTP log and find the reason why those were not delivered. If you see some error in the log but can't interpret, post that here, may be we could help.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial