IMsg - Vbscript problem - Item cannot be found in the collection corresponding to the requested name or ordinal

Hi Experts,

I've an asp page that i'm trying to email out with an attachment and html using the code below:

Dim iMsg
Set iMsg = CreateObject("CDO.Message")

Dim iConf
Set iConf = CreateObject("CDO.Configuration")

Dim Flds
Set Flds = iConf.Fields

With Flds
  ' assume constants are defined within script file
  .Item(cdoSMTPServer)            = ""
  .Item(cdoSMTPConnectionTimeout) = 10 ' quick timeout
  .Item(cdoURLGetLatestVersion)   = True
End With

With iMsg
   .To   = trim(email)
   .From = ""
   .Subject  = "confirmation of order number " & policyNo
   .AddAttachment "g:\abc.pdf"
   .CreateMHTMLBody "" & policyNo & "&email=yes", cdoSuppressAll
End With

But i'm getting the Item cannot be found in the collection corresponding to the requested name or ordinal error message on the   .Item(cdoSMTPServer)            = ""

Can anyone help at all?
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.

Please include the typelib..

<!--metadata type="typelib" UUID="CD000000-8B95-11D1-82DB-00C04FB1625D" name="CDO for Windows 2000 Type Library" -->

in your ASP page...
you cannot use ASP file here

.CreateMHTMLBody "" & policyNo & "&email=yes", cdoSuppressAll

use [.HTMLBody] instead

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
pjordannaAuthor Commented:
hi there,

thanks for your replies - i now get object doesn't support this property or method - 'HTMLBody'

any ideas?
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

pjordannaAuthor Commented:
sorry now i understand - with .htmlbody i need to actually write out the html code - i'd really prefer to just reference a web page if that's possible?
pjordannaAuthor Commented:
ok - i'm now using

Set objXML = Server.CreateObject("MSXML2.ServerXMLHTTP")
strURL = "http://www....etc, etc

to create a strURL variable that's scraping the page that i want with the asp variable in it...

I've changed to the '.HTMLBody =' method, and now i get no code errors if i rem out the .send, however if i put the .send line back in I get an 'access is denied' error - can anyone shed any light on this?

Many Thanks,
here's everything about ASP Mail
pjordannaAuthor Commented:

good grief that's frustating!

thanks for your comments - they all helped me get there in the end cos......


It's working at last - had to use an xml scrape to pull out the html and stuff it into the .HTMLBody part....

Here's the code - hope it helps anyone else with the same problem (trying to send an html email generated from a page with asp variables in the querystring and adding an attachment to it)

Set objXML = Server.CreateObject("MSXML2.ServerXMLHTTP")
strURL = "" & orderNo & "&email=yes"

objXML.Open "GET", strURL , false


If Err.Number = 0 Then               'no errors
If objXML.Status = 200 then          'url is valid
strOpen = objXML.ResponseText
Response.Write "Incorrect URL"
End if
Response.Write Err.Description
End If
Set objXML = Nothing

Set myMail=CreateObject("CDO.Message")
myMail.Subject="Confirmation of order number " & orderNo
myMail.AddAttachment "g:\web\attach.pdf"
myMail.HTMLBody =   strOpen
myMail.Configuration.Fields.Item _
'Name or IP of remote SMTP server
myMail.Configuration.Fields.Item _
("") _
'Server port
myMail.Configuration.Fields.Item _
("") _
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
Web Development

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.