And now I've successfully programmed the CDONTS to *dynamically* attach multiple files!! Mind you, I leaned heavily on a thread I found here:
http://forums.aspfree.com/archive/t-...le-with-CDONTS
Without further ado:
<%
'|| Globally declare:
'|| 1) my array of files
'|| 2) the string variable will fill it.
Dim arrFiles,myArray
'||------------------------------------
'|| Begin SendMail Procedure
'||------------------------------------
Sub SendMail(iNumber) '|| iNumber is just a unique value being
'|| pulled from our database, like an OrderID
'|| or CustomerID, etc.
Dim CDO_MAIL,iArrCount
BuildAttachment '|| Call "BuildAttachment" Function;
'|| This will loop through recordset
'|| and find files to put in array.
arrFiles = Split(myArray,",") '|| Fill arrFiles array with string
'|| from BuildAttachment function.
Set CDO_MAIL = Server.CreateObject("CDONTS.NewMail")
CDO_MAIL.To = "
[email protected]"
CDO_MAIL.From = "
[email protected]"
CDO_MAIL.Subject = "There are several files attached to this note."
CDO_MAIL.Body = "ATTENTION! Files attached!"
For iArrCount = LBound(arrFiles) To UBound(arrFiles)
CDO_MAIL.AttachFile(Server.MapPath(arrFiles(iArrCo unt)))
Next
CDO_MAIL.Send
End Sub
'||---------------------------------------------
'|| Begin BuildAttachment Function
'||---------------------------------------------
Function BuildAttachment(iNumber)
Dim cnx, rsFiles, myFile, intFileNum
'|| BUILD A SELECT STATEMENT HERE TO LOOP THROUGH
'|| DATABASE, ie, "SELECT * FROM v_Records
'|| "WHERE numID = " & iNumber
Set rsFiles = cnx.ExecuteQuery()
intFileNum = 0 '|| This counts the number of times we are
'|| going through the database and
'|| helps to keep attachment names unique.
Do While Not rsFiles.EOF
intFileNum = intFileNum + 1
myFile = rsFiles("myValue") & "_attchmt" & intFileNum & ".pdf"
'|| If there is more than one file, than make sure there
'|| are commas separating the names in the array.
'|| Otherwise, just fill it with the one name, no commas needed.
If intFileNum > 1 Then
myArray = myArray & "," & myFile
Else
myArray = myFile
End If
rsFiles.MoveNext
Loop
End Function
%>
That's pretty much all there was to it. Now all I need is a way to clean out my folder after saving all those pdf files to it ... that should be the easy part of this puzzle!
Hoping this helps someone,
Susan :)