I have some ASP code that I've "inherited" from my predecessor (no, it's not an option to update it at this time...It would take an act of not only Congress, but every other foreign country too) and I'm having an issue sending mail on one of the pages. It is an almost identical code snippet from the other page, but this one throws an error when I try to 'Send'.
Code below:
Set myMail=CreateObject("CDO.Message")
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
'Name or IP of remote SMTP server
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver")="localhost"
'Server port
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=25
myMail.Configuration.Fields.Update
myMail.Subject="Subject"
myMail.From=from_email
myMail.To=email
myMail.TextBody= "Body Text of message"
myMail.Send
The error thrown is:
Error Type:
(0x8004020F)
The event class for this subscription is in an invalid partition
I'd appreciate any and all help!!!
Thanks!
JFV
I had similar issues trying to get CDO to work. I found a really cool article on this website Why does CDO.Message give me 8004020F errors?
Here is the code I finally got to work. I could never get localhost to work as the SMTP Server. Find out what the name of the mail server is and make sure to use that name.
<!--METADATA TYPE="typelib" UUID="CD000000-8B95-11D1-82DB-00C04FB1625D" NAME="CDO for Windows 2000 Type Library" -->
<!--METADATA TYPE="typelib" UUID="00000205-0000-0010-8000-00AA006D2EA4" NAME="ADODB Type Library" -->
<%
Set cdoConfig = CreateObject("CDO.Configuration")
With cdoConfig.Fields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = "nameofmailservergoeshere"
.Update
End With
Set cdoMessage = CreateObject("CDO.Message")
With cdoMessage
Set .Configuration = cdoConfig
.From = "me@mywebsite.com"
.To = "you@yourwebsite.com"
.Subject = "Sample CDO Message"
.TextBody = "This is a a test message using CDO."
.Send
End With
Set cdoMessage = Nothing
Set cdoConfig = Nothing
%>
This seems to be an issue with the smtp server...
have a look at http://forums.aspfree.com/asp-development-5/the-event-class-for-this-subscription-is-in-an-invalid-103189.html
and also
http://www.powerasp.com/info/4558~General~info.htm