Importing attachment files to Notes from SQL BLOB column

Hi,

Not sure if this is the right forum for this, but I cross-posted this over at the Enterprise Integration board. I’m under an extremely tight deadline, and hopefully someone could help me out here.

I have a .NET web form that saves attachments as binary data in a BLOB column. I need to get that binary data from those columns, save the binary data as actual files, and attach those files to the appropriate Rich Text fields on the Notes form. I have code that does this correctly.

However, when you open the attachment from the Notes form, it isn’t formatted correctly, so .txt files sent over in this manner open as blank, .jpg files sent over open with the little red “x” indicating it’s not readable, etc. I’ve confirmed that the attachments are the correct file size – a 50 KB attachment I send over is still 50 KB on the Notes side. The file just isn’t usable.

Here’s the code I’m using for this:

==================

Set fld = fldLst2.Lookup(“attachment_type_c”) 'Determines what field file should be attached to

Select Case fld.Text(0)

Case “11” : str_attachFieldName = “Description”

Case “22” : str_attachFieldName = “Essay1”

Case “33” : str_attachFieldName = “Essay2”

Case “44” : str_attachFieldName = “Essay3”

Case “55” : str_attachFieldName = “Essay4”

Case “66” : str_attachFieldName = “Essay5”

Case “77” : str_attachFieldName = “Picture”

End Select

Set fld = fldLst2.Lookup(“attach_file_name_c”) 'File name of attachment

str_fileName = fld.Text(0)

str_extension = Strright(str_fileName, “.”)

Set fld = fldLst2.Lookup(“attachment_file_size_n”) 'Size of attachment

str_len = fld.Text(0)

Set fld = New LCField(LCTYPE_BINARY) 'Format LCField to binary to handle data

Set fld = fldLst2.Lookup(“attachment_file_data_d”) 'Actual attachment data - BLOB column

Set strm_this = fld.GetStream(1, LCSTREAMFMT_BLOB) 'Send to stream in BLOB format

fileNumber% = Freefile 'Create file to local disk for handling attachment data

file1 = "c:\temp" & str_fileName

Open file1 For Binary As fileNumber%

Put #fileNumber%, 1, strm_this.Value(0) 'Feed stream data into new binary-formatted file

Close #fileNumber% 'Saves file to disk

Set rti_attach = New NotesRichTextItem(doc_newNom, str_attachFieldName) 'Get RT field to attach to

Call rti_attach.EmbedObject(EMBED_ATTACHMENT, “”, file1, str_fileName) 'Attach new file to RT field

Kill file1 'Garbage collection for local disk

===================

I’ve stopped the script after the file is saved to disk, opened the file directly from disk, and the file is blank even from that point. So the problem must be with the way I’m looking up the BLOB data and formatting it from SQL, not the way I’m attaching it through the NotesRichTextField object.

I saw a solution at IBM - United States that involves a “file” LCConnection, setting up a special FILE field in the LCFieldList, etc. But it’s a huge overhaul of what I’ve already done, and I’m so close with this solution, there surely must be something I can tweak to get the binary data formatted correctly!

Let me know…any assistance is greatly appreciated. Thanks in advance!

Subject: importing attachment files to Notes from SQL BLOB column

What is the DIM for stream_this?

Subject: RE: importing attachment files to Notes from SQL BLOB column

stream_this is declared earlier in the script as an LCStream object.

Thanks!