We help IT Professionals succeed at work.

Error '80040211' in Autosend email program

Discusman
Discusman asked
on
20,848 Views
Last Modified: 2011-08-18
Here is what I have on my server:
mailenable installed (it includes SMTP service)
CDONTS.dll installed and registered successfully through command line
IIS 5.1
Windows XP
I can send and receive email using my own domain email address such as "Admin@mywebsite.com"

I did some research on this topic found out that Windows XP Pro no longer support CDONTS.dll components. So I switch my program to use CDOSYS.

I get an error when I tried to run the program
=================================
error '80040211'
/test2.asp, line 23

line 23: objMail.Send
================================
The complete program as follows:
==========================
<!--METADATA TYPE="typelib" UUID="CD000000-8B95-11D1-82DB-00C04FB1625D" NAME="CDO for Windows 2000 Library" -->
<!--METADATA TYPE="typelib" UUID="00000205-0000-0010-8000-00AA006D2EA4" NAME="ADODB Type Library" -->

Dim objMail
Set objMail = Server.CreateObject("CDO.Message")
Set objConfig = Server.CreateObject("CDO.Configuration")

'Configuration:
objConfig.Fields(cdoSendUsingMethod)=cdoSendUsingPort
objConfig.Fields(cdoSMTPServer)="localhost"
objConfig.Fields(cdoSMTPServerPort)=25
objConfig.Fields(cdoSMTPAuthenticate)=cdoBasic

'Update configuration
objConfig.Fields.Update
Set objMail.Configuration = objConfig

objMail.From ="admin@hotmail.com"
objMail.To = "user@hotmail.com"
objMail.Subject ="Contact from your site"
objMail.TextBody="This is a test for CDO.message"
objMail.Send

Set objMail=Nothing
Set objConfig=Nothing
=====================================
Comment
Watch Question

Commented:
I think you need to specify a mailserver on this line...

YOu have
objConfig.Fields(cdoSMTPServer)="localhost"

Try replacing localhost with the ip address or host name of the mailserver...
objConfig.Fields(cdoSMTPServer)="YOURMAILSERVERIP"

--------
D_M_D
Top Expert 2004

Commented:
Try it without any configuration settings.  Default should work fine!

Dim objMail
Set objMail = Server.CreateObject("CDO.Message")

objMail.Sender ="admin@hotmail.com"
objMail.To = "user@hotmail.com"
objMail.Subject ="Contact from your site"
objMail.TextBody="This is a test for CDO.message"
objMail.Send

Set objMail=Nothing
Set objConfig=Nothing


And it should be objMail.Sender, not objMail.From

If configuration is necessary, then I think it was the objMail.From thing...

Commented:
Are you sure you can some address aren't being blocked?  Try your code with a none hotmail address.

--------
D_M_D
Top Expert 2004

Commented:
As mentioned, Hotmail and RR accounts, and some others, do not allow relayed email like this most of the time!

But I think your problem is the From and Sender issue i mentioned above.

Author

Commented:
Now I get a different type of error:
==========================
CDO.Message.1 error '80040220'

The "SendUsing" configuration value is invalid.

/test3.asp, line 16
============================
Line 16: objMail.Send

Here is the complete program I tested with:
=============================
<!--
    METADATA
    TYPE="typelib"
    UUID="CD000000-8B95-11D1-82DB-00C04FB1625D"  
    NAME="CDO for Windows 2000 Library"
-->  
<%  
Dim objMail
Set objMail = Server.CreateObject("CDO.Message")

objMail.Sender ="admin@hotmail.com"
objMail.To = "myusername@yahoo.com"
objMail.Subject ="Contact from your site"
objMail.TextBody="This is a test for CDO.message"
objMail.Send

Set objMail=Nothing
Set objConfig=Nothing
   
Response.Redirect "RegistrationInProcess2.asp"
 
%>
Top Expert 2004

Commented:
Are you running this on your local machine or a host?  Looks like you just switched machines?

>IIS 5.1
>Windows XP
>I can send and receive email using my own domain email address such as "Admin@mywebsite.com"
Top Expert 2004

Commented:
You could also copy the cdonts.dll from a old machine, and install it on the XP machine and use your old code.

Commented:
Try this...Change the YOURMAILSERVERIPADDRESS to your mailserver

alorentz, it is From, I tested the following code and it works fine.

<%
Dim x
set x = Server.CreateObject("CDO.Message")
x.From = "admin@hotmail.com"
x.To = "myusername@yahoo.com"
x.Subject ="Contact from your site"
x.TextBody = "This is a test for CDO.message"
x.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "YOURMAILSERVERIPADDRESS"
x.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
x.Configuration.Fields.Update

x.Send
set x = nothing
%>

--------
D_M_D
Top Expert 2004

Commented:
Yeah, I see that From works, but it should be Sender....guess it supports both..

Author

Commented:
Like I said in my first post, I have everything installed on my machine including CDONTS.dll.

D M D,

Your code isn't working on my machine. I get this error now:
=====================================
error '8004020f'
The event class for this subscription is in an invalid partition

/test.asp, line 19
====================================
Line 19: x.Send

I used the following program for testing:
=====================================
<!--
    METADATA
    TYPE="typelib"
    UUID="CD000000-8B95-11D1-82DB-00C04FB1625D"  
    NAME="CDO for Windows 2000 Library"
-->  

<%
Dim x
set x = Server.CreateObject("CDO.Message")
x.From = "admin@hotmail.com"
x.To = "mekilldiablo@yahoo.com"
x.Subject ="Contact from your site"
x.TextBody = "This is a test for CDO.message"
x.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "192.168.0.101"
x.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
x.Configuration.Fields.Update

x.Send
set x = nothing


Response.Redirect "RegistrationInProcess2.asp"


%>

Commented:
That error is (see below)...
CONST LONG CDO_E_RECIPIENTS_REJECTED = 0x8004020FL
 
Which means that the e-mail was rejected by the server for some reason. Here are some things you can try to fix the problem:

Make sure the SMTP server allows anonymous (non-authenticated) relaying.
 
Check if the problem is specific to the domain name(s) used in the e-mail addresses of the recipients.  

Try using a SendUsing value of 1 (pickup) instead of 2 (port)

<!--
    METADATA
    TYPE="typelib"
    UUID="CD000000-8B95-11D1-82DB-00C04FB1625D"  
    NAME="CDO for Windows 2000 Library"
-->  

<%
Dim x
set x = Server.CreateObject("CDO.Message")
x.From = "admin@hotmail.com"
x.To = "mekilldiablo@yahoo.com"
x.Subject ="Contact from your site"
x.TextBody = "This is a test for CDO.message"
x.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "192.168.0.101"
x.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1
x.Configuration.Fields.Update

x.Send
set x = nothing


Response.Redirect "RegistrationInProcess2.asp"


%>

--------
D_M_D

Author

Commented:
Ok, I found this in activity event log of my SMTP service.
===========================================
02/16/04 17:38:17      SMTP-IN            324      69.22.241.239                  220 nyc-discusfanatics.com ESMTP MailEnable Service, Version: 1.71-- ready at 02/16/04 17:38:17      0      0
02/16/04 17:38:17      SMTP-IN            324      69.22.241.239      HELO      HELO diablo      250 Requested mail action okay, completed      43      13
02/16/04 17:38:17      SMTP-IN            324      69.22.241.239      MAIL      MAIL FROM: <admin@hotmail.com>      250 Requested mail action okay, completed      43      32
02/16/04 17:38:17      SMTP-IN            324      69.22.241.239      RCPT      RCPT TO: <mekilldiablo@yahoo.com>      503 This mail server requires authentication. Please check your mail client settings.      87      35
02/16/04 17:38:18      SMTP-IN            324      69.22.241.239      QUIT      QUIT      221 Service closing transmission channel      42      6
=========================================================

I am using Outlook Express to send email using my domain name email address. So I guess I have to check my settings in Outlook Express?

Commented:
It looks like it had a problem with yahoo.  It seems to need a username and password.

Hmm..

--------
D_M_D

Author

Commented:
Umm...
That's really weird. I have never heard of this before.

When I use my hotmail account to send email to my yahoo account, no problem. I might need to try to send to somewhere else?

Commented:
Try sending it to other address.  That seems to be the only part failing.

--------
D_M_D

Author

Commented:
Umm....

I tried send to my hotmail account. It doesnt work either.

However, it works when I sent it to my own domain name address "Admin@mywebsite.com"

I received email right after I run the program. This is really weird.

How can I modify the program, so it will send email to any type of mail site?

It seems that all the mail servers wouldn't accept my email.

Commented:
Sounds like there being blocked at the mailserver.  Your mailserver might be blocking certain outgoing addresses.

Are you getting the same "503 This mail server requires authentication. Please check your mail client settings. " in your log for hotmail and yahoo?

-------
D_M_D



Author

Commented:
Yes, the same message on hotmail account. It quits then displays "503 This mail server requires........." in my log.

Author

Commented:
If my mail server is blocking certain outgoing mails. Why I can send emails to anywhere when I send mail using my email client Outlook Express?

Author

Commented:
I got this piece of program on the internet. Can you help me modify it, so I  can test it in ASP?
The following program is in VB.Net
It sends username and password to the mail server.
=====================
Private Sub Page_Load(sender As Object, e As System.EventArgs)
   Dim mail As New MailMessage()
   mail.To = "me@mycompany.com"
   mail.From = "you@yourcompany.com"
   mail.Subject = "this is a test email."
   mail.Body = "Some text goes here"
   mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1") 'basic authentication
   mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "my_username_here") 'set your username here
   mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "super_secret") 'set your password here
   SmtpMail.SmtpServer = "mail.mycompany.com" 'your real server goes here
   SmtpMail.Send(mail)
End Sub 'Page_Load
=================================

Commented:
Because outlook provides the login information, Go to Outlook -->Tools Email Accounts

This might work to send the user name and password, but sounds risky.

 .Item(cdoSendUserName)    = "username"
 .Item(cdoSendPassword)     = "password"

--------
D_M_D



 

Commented:
Try tx.Fields.Add and if it doesn't work then try x.Configuration.Fields.Add

<%
Dim x
set x = Server.CreateObject("CDO.Message")
x.From = "admin@hotmail.com"
x.To = "mekilldiablo@yahoo.com"
x.Subject ="Contact from your site"
x.TextBody = "This is a test for CDO.message"
x.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "192.168.0.101"
x.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1
x.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1") 'basic authentication
x.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "my_username_here") 'set your username here
 x.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "super_secret") 'set your password here

x.Configuration.Fields.Update

x.Send
set x = nothing


Response.Redirect "RegistrationInProcess2.asp"


%>

Author

Commented:
In the "my_username_here", I can just make up any username? same to the password field, any pw?

Author

Commented:
Now I get this error message:
==========================
Microsoft VBScript compilation error '800a0414'

Cannot use parentheses when calling a Sub

/test.asp, line 17

x.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1") 'basic authentication
-------------------------------------------------------------------------------------^
================================

Author

Commented:
I managed to fix the previous error. But another new error pops up.
=======================
Microsoft VBScript runtime error '800a01b6'

Object doesn't support this property or method: 'Configuration.Fields.Add'

/test.asp, line 17
=================================
My program:
===========================
<!--
    METADATA
    TYPE="typelib"
    UUID="CD000000-8B95-11D1-82DB-00C04FB1625D"  
    NAME="CDO for Windows 2000 Library"
-->  

<%
Dim x
set x = Server.CreateObject("CDO.Message")
x.From = "admin@hotmail.com"
x.To = "mekilldiablo@yahoo.com"
x.Subject ="Contact from your site"
x.TextBody = "This is a test for CDO.message"
x.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "192.168.0.101"
x.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1
x.Configuration.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic authentication
x.Configuration.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername") = "MyUserName" 'set your username here
x.Configuration.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword")= "MyPassword" 'set your password here

x.Configuration.Fields.Update

x.Send
set x = nothing


Response.Redirect "RegistrationInProcess2.asp"


%>

Author

Commented:
Ok guys. I got the answer. There is nothing wrong with the ASP code. All I need to do is configure it in my Outlook.

Here is what I did:

Go to Tools< Account < Mail < Property < Servers < check the box "My server needs authentication"

Now my send email function is working.
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.