Link to home
Start Free TrialLog in
Avatar of pjordanna
pjordanna

asked on

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?
SOLUTION
Avatar of SaurabhBirla
SaurabhBirla

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pjordanna
pjordanna

ASKER

hi there,

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

any ideas?
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?
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,
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