troubleshooting Question

how to reference a record set field within CDO syntax

Avatar of Mark Drelinger
Mark DrelingerFlag for United States of America asked on
VB Script
2 Comments1 Solution56 ViewsLast Modified:
I'm trying to attach a file to an email via vbscript and CDO.  
The error is "Wrong number of arguments or invalid property assignment: 'objCDO.AttachFile'"

              objCDO.AttachFile (rsEQUIPInvoices.Fields.Item("InvoiceFileLocation").Value)

value from recordset is exactly as:
              "D:\inetpub\Media\EQUIP_Invoices\2019\12\13\I_I_229406.pdf"

I think its the way I'm referencing the field, but I can't remember the proper syntax.
Please advise.
Mark


Set objCDO = Server.CreateObject("Cdonts.NewMail")
objCDO.BodyFormat =0 ' 0 is a plain text, 0 "zero" is a HTML
objCDO.MailFormat = 0 ' 1 is a plain text, 0 "zero" is mime format

objCDO.From = Request("varFrom")
objCDO.To = Request("varTo")

objCDO.Subject = "Invoices from Schmidt Equipment"
objCDO.Body = "Invoices from Schmidt Equipment"

While ((Repeat1__numRows <> 0) AND (NOT rsEQUIPInvoices.EOF))
      objCDO.AttachFile=(rsEQUIPInvoices.Fields.Item("InvoiceFileLocation").Value)
        Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  rsEQUIPInvoices.MoveNext()
Wend

objCDO.Send
Set objCDO = Nothing
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros