Avatar of Mark Drelinger
Mark Drelinger
Flag for United States of America asked on

how to reference a record set field within CDO syntax

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
VB Script

Avatar of undefined
Last Comment
Mark Drelinger

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
RobSampson

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Mark Drelinger

ASKER
Thank you.
Your help has saved me hundreds of hours of internet surfing.
fblack61