Cdonts failing Server object error 'ASP 0177 : 800401f3'

I am using XP SP2
This code was working OK but I am now getting this error.
Can anyone please think why this is occouring.
Server object error 'ASP 0177 : 800401f3'
Server.CreateObject Failed
/fb/forgotten_password.asp, line 34
800401f3
Thanks,
John

<%
if Request("Selected") <> "" then
UserEmail=Request("Email")
if not UsersRS.eof then
UserPassword=UsersRS("CustomerPassword")
SendEmail
Response.Redirect "forgotten_password.asp?success=true"
else
Response.Redirect "forgotten_password.asp?failed=true"
end if
end if
      function SendEmail
            Set objCDOMail = Server.CreateObject("CDONTS.NewMail") ' **************Line 34
            objCDOMail.From = "xxx@xxx.co.uk"
            objCDOMail.To = UserEmail
            objCDOMail.Subject = "Forgotten Password for Products Website"
            objCDOMail.Body = mailbody
            objCDOMail.Send
            Set objCDOMail = Nothing
      end function

function mailbody
tmpstr=""
Set objXML = Server.CreateObject("Microsoft.XMLDOM")
objXML.validateOnParse=True
objXML.load(Server.MapPath("xml/forgot_password.xml"))
set objNodeXML=objXML.documentElement
tmpstr=objNodeXML.selectSingleNode("body").Text
Set objXML = Nothing
tmpstr=replace(tmpstr,"#UserEmail#",UserEmail)
tmpstr=replace(tmpstr,"#UserPassword#",UserPassword)
mailbody=tmpstr
end function
%>
johnhardyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

kevp75Commented:
try changing your function to

     function SendEmail(UserEmail, mailbody)
          Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
          objCDOMail.From = "xxx@xxx.co.uk"
          objCDOMail.To = UserEmail
          objCDOMail.Subject = "Forgotten Password for Products Website"
          objCDOMail.Body = mailbody
          objCDOMail.Send
          Set objCDOMail = Nothing
     end function

then change your call to it to:
Call SendEmail(UserEmail, mailbody)
0
johnhardyAuthor Commented:
Thanks,
However I received a similar error
Server object, ASP 0177 (0x800401F3)
Invalid class string
 line 35
I wondered could cdonts have gone missing?  I lost jmail recently. How would I check please?

The ammended code is

<%
if Request("Selected") <> "" then
UserEmail=Request("Email")
if not UsersRS.eof then
UserPassword=UsersRS("CustomerPassword")
'SendEmail
Call SendEmail(UserEmail, mailbody)
Response.Redirect "forgotten_password.asp?success=true"
else
Response.Redirect "forgotten_password.asp?failed=true"
end if
end if
      function SendEmail(UserEmail, mailbody)
            Set objCDOMail = Server.CreateObject("CDONTS.NewMail")' *******LINE 35
            objCDOMail.From = "jules@charon.co.uk"
            objCDOMail.To = UserEmail
            objCDOMail.Subject = "Forgotten Password for Products Website"
            objCDOMail.Body = mailbody
            objCDOMail.Send
            Set objCDOMail = Nothing
      end function
0
Carl TawnSystems and Integration DeveloperCommented:
Have there been any upgrades to your servers recently ?

Try using CDO.Message instead:

   Set objCDOMail = Server.CreateObject("CDO.Message")
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

Carl TawnSystems and Integration DeveloperCommented:
Alternatively you will need to copy and register cdonts.dll from a Win2K machine to your XP machine.
0
kevp75Commented:
you lost jmail?  Sounds like you may have some kind of security breach, as components do not just disapear.

check this out.  http://www.pensaworks.com/prg_com.asp (you'll have to download the script, unzip it, then upload it to your server.) It will test for the installed ASP components on your server.  If you have another email component you should switch to that component rather than using CDONTS, as CDONTS is rather unreliable.
0
johnhardyAuthor Commented:
I tried
Set objCDOMail = Server.CreateObject("CDO.Message")
the error moved down a little
Microsoft VBScript runtime (0x800A01B6)
Object doesn't support this property or method: 'objCDOMail.Body'
Code:
'Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
            Set objCDOMail = Server.CreateObject("CDO.Message")
            objCDOMail.From = "jules@charon.co.uk"
            objCDOMail.To = UserEmail
            objCDOMail.Subject = "Forgotten Password for Products Website"
            objCDOMail.Body = mailbody
            objCDOMail.Send
            Set objCDOMail = Nothing

=====================
I also found this article by Jules at Charon
http://www.charon.co.uk/aspnetforums/ShowPost.aspx?PostID=5005 passing to
http://www.charon.co.uk/content.aspx?CategoryID=27&ArticleID=26 
I am using Localhost.
However when I look at the example I cant see how to apply this to the present code.
Thanks
John
0
Carl TawnSystems and Integration DeveloperCommented:
You need to use either:

    objCDOMail.TextBody

Or:

   objCDOMail.HTMLBody

Depending on your requirements.
0
kevp75Commented:
right..go back to using Server.CreateObject("CDONTS.NewMail")

the error is somewhere in that mailbody function

try this out

Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
          objCDOMail.From = "jules@charon.co.uk"
          objCDOMail.To = "jules@charon.co.uk"'I am assuming this is your email address
          objCDOMail.Subject = "Forgotten Password for Products Website"
          objCDOMail.Body = "Here is your your password..."
          objCDOMail.Send
          Set objCDOMail = Nothing

just to see what happens
0
johnhardyAuthor Commented:
Thanks KEVP
I have tried both            
'Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
            and Set objCDOMail = Server.CreateObject("CDO.Message")
using CDONTS gives an error at line 35
Using CDO the error is at line 40 -- Object doesn't support this property or method: 'objCDOMail.Body'
That section now reads
<%
if Request("Selected") <> "" then
UserEmail=Request("Email")
if not UsersRS.eof then
UserPassword=UsersRS("CustomerPassword")
'SendEmail
Call SendEmail
Response.Redirect "forgotten_password.asp?success=true"
else
Response.Redirect "forgotten_password.asp?failed=true"
end if
end if
      function SendEmail
            'Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
            Set objCDOMail = Server.CreateObject("CDO.Message")
            objCDOMail.From = "info@net100.co.uk"
            objCDOMail.To = "john@net100.co.uk"
            objCDOMail.Subject = "Forgotten Password for Products Website"
            objCDOMail.Body = "Here is your password"
            objCDOMail.Send
            Set objCDOMail = Nothing
      end function

function mailbody
tmpstr=""
Set objXML = Server.CreateObject("Microsoft.XMLDOM")
objXML.validateOnParse=True
objXML.load(Server.MapPath("xml/forgot_password.xml"))
set objNodeXML=objXML.documentElement
tmpstr=objNodeXML.selectSingleNode("body").Text
Set objXML = Nothing
tmpstr=replace(tmpstr,"#UserEmail#",UserEmail)
tmpstr=replace(tmpstr,"#UserPassword#",UserPassword)
mailbody=tmpstr
end function
%>
0
Carl TawnSystems and Integration DeveloperCommented:
As per my last post, you need to use TextBody or HTMLBody with CDO:

i.e.

          Set objCDOMail = Server.CreateObject("CDO.Message")
          objCDOMail.From = "info@net100.co.uk"
          objCDOMail.To = "john@net100.co.uk"
          objCDOMail.Subject = "Forgotten Password for Products Website"
          objCDOMail.TextBody = "Here is your password"
          objCDOMail.Send
          Set objCDOMail = Nothing
0
kevp75Commented:
ok...using CDO.Message, change objCDOMail.Body to either objCDOMail.TextBody or objCDOMail.HTMLBody depending on what the content you are trying to send is.

if you are using the mailbody function then use HTMLBody
0
johnhardyAuthor Commented:
Thanks very much, I actually got a result,
The page was sent and I received back an email which said Here is your password.
However no password was included

I imagine its to do with the next part of the code,
I suspect its something to do with the file forgot_password.xml where the code looks like the email which should be received!

Can you pls advise?

function mailbody
tmpstr=""
Set objXML = Server.CreateObject("Microsoft.XMLDOM")
objXML.validateOnParse=True
objXML.load(Server.MapPath("xml/forgot_password.xml"))
set objNodeXML=objXML.documentElement
tmpstr=objNodeXML.selectSingleNode("body").Text
Set objXML = Nothing
tmpstr=replace(tmpstr,"#UserEmail#",UserEmail)
tmpstr=replace(tmpstr,"#UserPassword#",UserPassword)
mailbody=tmpstr
end function
0
Carl TawnSystems and Integration DeveloperCommented:
You'll have to test that block to see if it is retrieving the value from the XML document correctly.
0
kevp75Commented:
your code for the mailbody function looks correct, and you shouldn't have gotten a password, baces all you sent was "Here is your password"  :)

try setting objCDOMail.HTMLBody = mailbody

there is something wrong with the mailbody function, it throws out a, 'Object Required 'objNodeXML'' error for me....trying to work it out now
0
kevp75Commented:
i hate to ask for it, but can you supply the code for

xml/forgot_password.xml
0
Carl TawnSystems and Integration DeveloperCommented:
Initially for the purpose of debug, try changing your function to:

Function mailbody

    tmpstr=""

    Set objXML = Server.CreateObject("Microsoft.XMLDOM")
    objXML.validateOnParse=True
    bOK = objXML.load(Server.MapPath("xml/forgot_password.xml"))
    If Not bOK Then
       Response.Write "Failed to load XML": Response.Flush
    End If

    set objNodeXML=objXML.documentElement

    Set objNodeXML = objNodeXML.selectSingleNode("body").Text
    If objNodeXML Is Nothing Then
        Response.Write "Failed retrieving body node": Response.Flush
    End If

    tmpstr=objNodeXML.selectSingleNode("body").Text
    Set objXML = Nothing

    tmpstr=replace(tmpstr,"#UserEmail#",UserEmail)
    tmpstr=replace(tmpstr,"#UserPassword#",UserPassword)

    If Len(tmpstr) = 0 Then
        Response.Write "tmpstr is empty": Response.Flush
    End If

    mailbody=tmpstr

End Function
0
johnhardyAuthor Commented:
i hate to ask for it, but can you supply the code for
No problem. I went for a walk!

<?xml version="1.0"?>
<root>
<body>
<![CDATA[
Hello,
Here is your Username/Password for Website:-
Your User Name is - #UserEmail#
Your Password is - #UserPassword#

Best Regards
]]>
</body>
</root>


0
Carl TawnSystems and Integration DeveloperCommented:
In that case, change this line:

    tmpstr=objNodeXML.selectSingleNode("body").Text

To:

    tmpstr=objNodeXML.selectSingleNode("/root/body").Text
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kevp75Commented:
ok...the function is fine, I would try using that objCDOMail.HTMLBody = mailbody see where that gets ya.

I am assuming that the Username comes from the form itself and UserPassword is coming from a database (or XML file, or text file or something)

0
johnhardyAuthor Commented:
Well thank you both so very much.

Looks like finally we got there.

I have increased the points sorry I have to accept only one answer.

Regards

John



0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.