Sending e-mail with CDO

I'm having a little trouble with my code.

It gives me this error message:

ADODB.Fields error '800a0bb9'

Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.

/LABS/Lab8/example1.asp, line 8

Line 8 is this: .Item(cdoSendUsingMethod)=2

Can someone please help me?


This is my whole code:

<%
sch="http://schemas.microsoft.com/cdo/configuration/"
'set the CDO object
Set cdoConfig=CreateObject("CDO.Configuration")

'apply data to CDO properties, port number and server name
With cdoConfig.Fields
      .Item(cdoSendUsingMethod)=2
      .Item(cdoSMTPServer)= "smtphm.sympatico.ca"
      .Item(cdoSMTPAuthenticate)=1
      .Item(cdoSendUsername)="username"
      .Item(cdoSendPassword)="password"
      .update
End With

'begin the message section
Set cdoMessage=CreateObject("CDO.Message")

'add data to e-mail properties
With cdoMessage
      Set .Configuration=cdoConfig
      .From="runthatshit@hotchick.com"
      .To="sh00tar@yahoo.ca"
      .Subject="WANNA SEE SOMETHING....??"
      .TextBody="Haha.... Fooled You!!!"
      .AddAttachment "c:\test.txt"
      .Send
End With

'release objects and memory
Set cdoMessage=Nothing
Set cdoConfig=Nothing
%>
sh00tarAsked:
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.

WillibobCommented:
I suspect that the problem is because you need to enclose the Item arguments in double quotes:

 .Item("cdoSendUsingMethod")=2

Have a look here (http://www.w3schools.com/asp/asp_send_email.asp) if that doesn't sort it.

Bill
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
WillibobCommented:
Actually the problem lies with the fact that you are using late binding 'CreateObject("CDO.Message")' and are then using CDO constants as Item arguments.

Use the method contained within the link I gave in my previous post. I've used this method successfully.

Bill
0
Cherukuri30Service EngineerCommented:
Guess Metadata is missing try adding the below code in your page

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

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.