Link to home
Start Free TrialLog in
Avatar of Steve Bohler
Steve BohlerFlag 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?
Avatar of zc2
zc2
Flag of United States of America image

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.
Avatar of 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
Avatar of zc2
zc2
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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?
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.
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.
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

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

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
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.
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.
Ok, I’ll try that.

Is it possible to relay email from the smtp server over to our remote exchange server?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
Thanks so much!!!
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.