views:

49

answers:

0

A file is submitted, that file is put into a blob in a database (.AppendChunk), and that file should also emailed.

What I want to do is:
File is parsed from the form data into a variable (done).
Variable is inserted into database (rs(key).AppendChunk var) (done).
That variable is attached to an email (failing).
However, if I read back what I inserted into the recordset, I can attach that:

rs(aKey).AppendChunk aFile
aFile = rs(aKey)

For the email, I am using:

Dim objMail: Set objMail = CreateObject("CDO.Message")
' ... other fields set here ...
Dim objParts: Set objParts = objMail.Attachments.Add
objParts.ContentMediaType = "application/octet-stream"
objParts.ContentTransferEncoding = cdoBase64
objParts.Fields(cdoContentDisposition).Value = "attachment;filename=""Z.doc"""
objParts.Fields.Update
Dim objStream: Set objStream = objParts.GetDecodedContentStream
objStream.Write aFile  ' Error here, depending.
objStream.Flush
objMail.Send
Set objMail = Nothing

If I use the same data as was added to the database, I get this error message:
ADODB.Stream (0x800A0BB9): Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.

If I read the key back from the recordset, it submits without error.

So, how do I duplicate whatever .AppendChunk is doing? And what exactly is .AppendChunk doing?