Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2004-11-04
7
Medium Priority
?
397 Views
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)            = "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?
0
Comment
Question by:pjordanna
  • 4
  • 2
7 Comments
 
LVL 1

Assisted Solution

by:SaurabhBirla
SaurabhBirla earned 600 total points
ID: 12493312
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
 
LVL 13

Accepted Solution

by:
davidlars99 earned 900 total points
ID: 12494276
you cannot use ASP file here

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

use [.HTMLBody] instead
0
 

Author Comment

by:pjordanna
ID: 12512100
hi there,

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

any ideas?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:pjordanna
ID: 12512140
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
 

Author Comment

by:pjordanna
ID: 12512354
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
 
LVL 13

Expert Comment

by:davidlars99
ID: 12512947
here's everything about ASP Mail

http://www.w3schools.com/asp/asp_send_email.asp
0
 

Author Comment

by:pjordanna
ID: 12517085
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

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
CTAs encourage people to do something specific to show interest in your company, product or service. Keep reading to learn why CTAs should always be thought of as extremely important, albeit small, sections of websites.
This video teaches users how to migrate an existing Wordpress website to a new domain.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses
Course of the Month21 days, 6 hours left to enroll

810 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