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)            = "mail.xyz.net"
  .Item(cdoSMTPConnectionTimeout) = 10 ' quick timeout
  .Item(cdoURLGetLatestVersion)   = True
  .Update
End With

With iMsg
   .To   = trim(email)
   .From = "sales@abc.com"
   .Subject  = "confirmation of order number " & policyNo
   .AddAttachment "g:\abc.pdf"
   .CreateMHTMLBody "http://www.server.co.uk/letter.asp?policyNo=" & policyNo & "&email=yes", cdoSuppressAll
   .send
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)            = "mail.xyz.net"
line.

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

SaurabhBirlaCommented:
Please include the typelib..

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

in your ASP page...
0
davidlars99Commented:
you cannot use ASP file here

.CreateMHTMLBody "http://www.server.co.uk/letter.asp?policyNo=" & policyNo & "&email=yes", cdoSuppressAll

use [.HTMLBody] instead
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
pjordannaAuthor Commented:
hi there,

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

any ideas?
0
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?
0
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,
0
davidlars99Commented:
here's everything about ASP Mail

http://www.w3schools.com/asp/asp_send_email.asp
0
pjordannaAuthor Commented:
AAAARRRRRRRRRRRRRRRGGGGGGGGGGHHHHHHHHH!!!!!!!!!!

good grief that's frustating!

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


YYYYYYYYYYYYYYYYIIIIIIIIIIIIIIIIIIPPPPPPPPPPPPPPPPPPEEEEEEEEEEEEEEEE!!!!

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 = "http://www.site.co.uk/web/letter.asp?orderNo=" & orderNo & "&email=yes"

objXML.Open "GET", strURL , false

objXML.Send

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

      
Set myMail=CreateObject("CDO.Message")
myMail.Subject="Confirmation of order number " & orderNo
myMail.From="sales@site.com"
myMail.To=trim(email)
myMail.AddAttachment "g:\web\attach.pdf"
myMail.HTMLBody =   strOpen
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.Send
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
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.