Link to home
Start Free TrialLog in
Avatar of Mark Drelinger
Mark DrelingerFlag 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
ASKER CERTIFIED SOLUTION
Avatar of RobSampson
RobSampson
Flag of Australia image

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 Mark Drelinger

ASKER

Thank you.