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.Configur ation")
Dim Flds
Set Flds = iConf.Fields
With Flds
' assume constants are defined within script file
.Item(cdoSMTPServer) = "mail.xyz.net"
.Item(cdoSMTPConnectionTim eout) = 10 ' quick timeout
.Item(cdoURLGetLatestVersi on) = 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?
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.Configur
Dim Flds
Set Flds = iConf.Fields
With Flds
' assume constants are defined within script file
.Item(cdoSMTPServer) = "mail.xyz.net"
.Item(cdoSMTPConnectionTim
.Item(cdoURLGetLatestVersi
.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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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?
ASKER
ok - i'm now using
Set objXML = Server.CreateObject("MSXML 2.ServerXM LHTTP")
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,
Set objXML = Server.CreateObject("MSXML
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,
ASKER
AAAARRRRRRRRRRRRRRRGGGGGGG GGGHHHHHHH HH!!!!!!!! !!
good grief that's frustating!
thanks for your comments - they all helped me get there in the end cos......
YYYYYYYYYYYYYYYYIIIIIIIIII IIIIIIIIPP PPPPPPPPPP PPPPPPEEEE EEEEEEEEEE EE!!!!
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("MSXML 2.ServerXM LHTTP")
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.M essage")
myMail.Subject="Confirmati on of order number " & orderNo
myMail.From="sales@site.co m"
myMail.To=trim(email)
myMail.AddAttachment "g:\web\attach.pdf"
myMail.HTMLBody = strOpen
myMail.Configuration.Field s.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
'Name or IP of remote SMTP server
myMail.Configuration.Field s.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") _
="localhost"
'Server port
myMail.Configuration.Field s.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") _
=25
myMail.Configuration.Field s.Update
myMail.Send
good grief that's frustating!
thanks for your comments - they all helped me get there in the end cos......
YYYYYYYYYYYYYYYYIIIIIIIIII
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("MSXML
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.M
myMail.Subject="Confirmati
myMail.From="sales@site.co
myMail.To=trim(email)
myMail.AddAttachment "g:\web\attach.pdf"
myMail.HTMLBody = strOpen
myMail.Configuration.Field
("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
'Name or IP of remote SMTP server
myMail.Configuration.Field
("http://schemas.microsoft.com/cdo/configuration/smtpserver") _
="localhost"
'Server port
myMail.Configuration.Field
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") _
=25
myMail.Configuration.Field
myMail.Send
ASKER
thanks for your replies - i now get object doesn't support this property or method - 'HTMLBody'
any ideas?