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

Posted on 2004-11-04
Last Modified: 2008-01-09
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?
Question by:pjordanna
    LVL 1

    Assisted Solution

    Please include the typelib..

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

    in your ASP page...
    LVL 13

    Accepted Solution

    you cannot use ASP file here

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

    use [.HTMLBody] instead

    Author Comment

    hi there,

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

    any ideas?

    Author Comment

    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?

    Author Comment

    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,
    LVL 13

    Expert Comment

    here's everything about ASP Mail

    Author Comment


    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 _
    ("") _

    Featured Post

    Courses: Start Training Online With Pros, Today

    Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

    Join & Write a Comment

    Building “do-it-yourself” web sites has become an epidemic. There are so many blogs, web sites and even books that "teach" you how to build your web site in a few extremely simple and easy steps. Building a web site has become easier than boiling an…
    Problem to be resolved in this article Currently, development of website and web application can be done without writing thousands of lines of programming code by hand. Description This can be done through by using a open source framework such …
    This video teaches users how to migrate an existing Wordpress website to a new domain.
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now