Solved

Geting error 80040211 trying to send email with CDO through an Exchange Server...???

Posted on 2007-04-10
14
7,012 Views
Last Modified: 2010-05-07
I've had a script setup using CDO to send emails through our Exchange Server for about 2 or 3 months.  I include a username/password in my code for auth. and it works great.

All of a sudden I've started getting random 80040211 errors back on the .Send line in my scripts.  It's happening often, but there are also quite a few times that it works without any error.  Very confusing.

I Googled the error and the only information I could find had to do with authentication or the length of the message body being sent.  Auth. is good to go so I went ahead and tried one with nothing but the word "test" in the MailBody.  That worked just fine.  So, it seems that I'm having an issue with the length of the email messages..???

Why would this suddenly start happening and how can I fix it?  Any information on this would be greatly appreciated.  Thanks!
0
Comment
Question by:Andrew Angell
  • 6
  • 4
  • 3
  • +1
14 Comments
 
LVL 19

Assisted Solution

by:BrianGEFF719
BrianGEFF719 earned 100 total points
ID: 18885897
Solution Taken from Thread:
 http://www.dbforums.com/t884514.html


This is just a work around solution. Still not sure which of the following is causing the HTML Body's with lines over 1022 glitch: Windows Server 2003, IIS 6.0, SMTP, CDOSYS or the gateway. If anyone narrows it down. Let me know!

The workaround involves running a function on the HTMLBody that inserts a chr(13) every x < 1022 characters. You can test to see how close to 1022 you want to get.

The function code can be found at

http://www.petenelson.com/aspwatch/ASPWatch%20%20WordWrap%20Function.htm

and the function call will look like this

HTMLBody = WordWrap(HTMLBody, 1000, chr(13), false)

Hope that helps!
0
 
LVL 22

Accepted Solution

by:
WMIF earned 400 total points
ID: 18886042
the rfc for smtp communication specifies that the body lines cannot be longer than 1000 characters.  some smtp servers try to break that up, but others freeze up.  if you are using html formating, i typically will use a simple function on the text:

replace(text,">",">" & vbcrlf)

this will place a line break after every html tag.  it will not affect the formatting of the document whatsoever.

SMTP RFC:
http://tools.ietf.org/html/rfc821#page-42
ESMTP RFC:
http://tools.ietf.org/html/rfc2821#page-54

scroll down a tad looking for "text line".
0
 
LVL 11

Author Comment

by:Andrew Angell
ID: 18887406
WMIF:  I used your method and it seems to have worked!  Thank you both for your information!!
0
 
LVL 19

Expert Comment

by:BrianGEFF719
ID: 18887442
@angelleye: If you have a text string that is too long that method would not work. Just becareful, you might consider doing a replace on a more common charecter, such as a period.
0
 
LVL 19

Expert Comment

by:BrianGEFF719
ID: 18887445
By text string I mean a string that contains no html.
0
 
LVL 11

Author Comment

by:Andrew Angell
ID: 18900537
Awww....turns out I was wrong.  I swear right after making this change I tested about 10 times and they all worked perfectly.  I came in today and it's not working again.  I'm even trying to send emails with "" (nothing) as the email body and it won't go through.  Some, though, are still working.  

do I need to open a new question...????  any ideas what's going on?  i'm at a complete loss now.
0
 
LVL 22

Expert Comment

by:WMIF
ID: 18902051
you say that it was working previously, right?  has there been any change at all on either server?  windows updates, patches, configurations, anything?
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 11

Author Comment

by:Andrew Angell
ID: 18902216
Yes, it worked for a good 2 months or so and then our server admin installed SP2 on the server.  We started experiencing the random problems and with info from you guys and some people on microsoft technet forums I was told of the changes in SP2 that only allow 1000 characters on a line in email.  

I added your Replace(), WMIF, and ran about 10 tests and they all worked perfectly.  So I figured the problem was solved.  then I come in today and it's very hit and miss again.  sometimes it works, sometimes it doesn't.  even with nothing in the mailbody.

0
 
LVL 22

Expert Comment

by:WMIF
ID: 18902638
what OS is this server running?
0
 
LVL 11

Author Comment

by:Andrew Angell
ID: 18932819
Server is running Windows Server 2003.  This is getting very frustrating.  I started messing around with my web checkout again the other day and I went through probably 20 of them without getting a single error when it sent emails.  I was afraid to actually upload those pages, though, since I had just done that the day before and the next day it didn't work again.

So now it's been 2 days since I was testing all of those orders successfully and now suddenly my tracking emails, which never had the problem before, have the problem as of last night and today. I can't get them to run cuz the first one it tries to send returns the same error on myMail.Send.

:(  As confused as ever.
0
 
LVL 11

Author Comment

by:Andrew Angell
ID: 18932945
I ran that tracking email script twice and it didn't work either time.  I posted the response here.  I just ran it again a 3rd time...havn't touched a thing in the script or on the server...and it workd this time!

i'm lost.
0
 
LVL 11

Author Comment

by:Andrew Angell
ID: 18933020
I'm gonna go ahead and post a new message for this and add a link back to this thread.  Hope that's not a bad thing with board rules..??
0
 
LVL 22

Expert Comment

by:WMIF
ID: 18933563
>>Hope that's not a bad thing with board rules..??

not at all.  you might want to include the windows 2003 zone to see if there is an issue with the server itself.  that is what im leaning towards because of the randomness of this problem.
0
 

Expert Comment

by:JCMJ
ID: 32661967
Hi,

I tried all the stuff mentioned above but still had problems..
I actually found the following:

Lets imagine you use "mail.yourdomain.com" as the mail server for the CDOSYS configuration, and sales@yourdomain.com with its password as the login details. Your code will work as long as your CDO.Message Object does not try and send emails to email addresses on that same domain "yourdomain.com"..

I would like to get feedback on this, maybe some of you have been sending emails to email addresses sitting on the same domain as the authentication email, and that also causes this error code.
That would explain why your code only works sometimes... When you send to domains (emails) like *@yahoo.com the code will work, as soon as you send to any emails *.yourdomain.com the code causes the error.

Took me a lot of trial and error to get to this. Microsoft documentation on CDOSYS mentions nothing about it.
Just another example of Microsoft products not working.
 

Riaan
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now