Avatar of Steve Bohler
Steve Bohler
Flag for United States of America asked on

Error sending out email with CDO.Message

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?
ASP

Avatar of undefined
Last Comment
zc2

8/22/2022 - Mon
zc2

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.
Steve Bohler

ASKER
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.
ASKER CERTIFIED SOLUTION
zc2

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Scott Fell

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?
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Steve Bohler

ASKER
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.
zc2

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.
Steve Bohler

ASKER
zc2,

Not sure how to do that, unfortunately.

Steve
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
zc2

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.
zc2

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.
Steve Bohler

ASKER
OK, made the edits. Still nothing in the folder though. Am I missing a step?
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
zc2

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

Steve Bohler

ASKER
OK, I've got that working.

What should I do with the files it is creating?
zc2

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\
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Steve Bohler

ASKER
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)?
zc2

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.
Steve Bohler

ASKER
If I use that directory, I get an Access Denied error in my code.
Your help has saved me hundreds of hours of internet surfing.
fblack61
zc2

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

Steve Bohler

ASKER
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
Steve Bohler

ASKER
It seems it allows emails to go out when from one domain, but not another. Is there a place where I can control that?
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
zc2

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.
Steve Bohler

ASKER
Thanks.

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

Where do I set logging?
zc2

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.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Steve Bohler

ASKER
Ok, I’ll try that.

Is it possible to relay email from the smtp server over to our remote exchange server?
SOLUTION
zc2

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Scott Fell

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.
Steve Bohler

ASKER
Thanks so much!!!
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Steve Bohler

ASKER
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.
zc2

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.