Attachments doesn’t open in browser

I have strange problem, my code creates a file (named as .xls & not using excel objects) and attaches it to a document. When I open this document in my browser (IE) I can see the attachment but it doesn’t open when trying to do so.

I have tried opening from Notes Client, it works fine. I noticed the properties show file size as “ 0 bytes (?) “. There is no error reported in the log file.

Any suggestions to make this work ie to open the attachment in the document through browser

Here is my code

Sub ExcelExport

On Error Goto ErrorHandle

Dim destDoc As NotesDocument

Dim rtitem As NotesRichTextItem

Dim object As NotesEmbeddedObject

Dim coll As Long



fileHandle("ExcelExport") = Freefile()

coll = vw.FTSearch( strSearch, 0 )



‘ Setting the directory path

sysPath = session.GetEnvironmentString("Directory", True)



Open  sysPath & "\domino\html\" & fileName  For Output As fileHandle("ExcelExport")	



Dim strRecHeader As String

Forall c In vw.Columns

	strRecHeader =	strRecHeader & c.Title & strDelimiter

End Forall

Print # fileHandle("ExcelExport"), strRecHeader



Set doc = vw.GetFirstDocument

While Not (doc Is Nothing)

	counter = counter +1

	Dim strRecord As String

	strRecord = ""

	For j = 0 To vw.ColumnCount-1

		strRecord = strRecord & doc.ColumnValues(j) & strDelimiter

	Next

	

	Print #fileHandle("ExcelExport"), strRecord

	Set doc = vw.GetNextDocument(doc)

Wend



' Create Document and to the file generated & delete it from the local file system.

Set destDoc = db.CreateDocument

destDoc.Form = "DownloadFiles"

Call destDoc.Save( True, True )

Set rtitem = New NotesRichTextItem( destDoc, "fileName" )

Set object = rtitem.EmbedObject(EMBED_ATTACHMENT, "", sysPath & "\domino\html\" & fileName)

Call destDoc.Save( True, True )



Close fileHandle("Export")

Kill sysPath & "\domino\html\" & fileName

	

destDocURL = "http://"& curDoc.srvName(0) & "/" & curDoc.Path(0) & "/Dall/" & destDoc.UniversalID & "?OpenDocument"

'Prepare HTML Page for user to view results & save the file

Call vw.Clear



Exit Sub

ErrorHandle:

Print  "Error in data export  " & Error & " Please contact admin with the error details"

Err = 0

Resume Next	

End Sub

Subject: RE: Attachments doesn’t open in browser

I think maybe you should close the file before you attach it. Operating systems tend to buffer file output.

Subject: RE: Attachments doesn’t open in browser

Thanks for the hit, when I did as you have metioned, it worked when i am running on a localhost but not on the server.

Subject: RE: Attachments doesn’t open in browser

Just for kicks, try not deleting the file and see whether that makes a difference. File attaching, I have noticed, sometimes there is a short delay before the attachment is complete, and if you delete the file too soon there is trouble. There’s perhaps some background processing happening when it runs on the server.

You might need to build in a short delay, or save up all the filenames you need to delete and do them all at the end.

Subject: RE: Attachments doesn’t open in browser

I have the same problem. The very strage thing in this issue is that the attachments (generated and attached by script) can be viewed and opened from Notes client without any problem but impossible from web

But changing the code is not a complete solution in my case because we have loooots of documents with those “0 bytes” attachment but working in Notes (new code may be prevent future problems but not solves how to open the current ones)

In my case we are making the original database as web enabled and I discovered that the users will be unable to access to their attachment from web.

Any clue to find a way to open the attachments? I tryed to make some URL "$File, blah blah) but in all cases I get an empty file

Thanks!