GetAttachment returns Nothing, Unicode in attachment name

Hello.

I have written an application with Visual Basic 6 that goes through all the documents in a Lotus Notes database and extracts all of the attached files it can find. I find all of the attachments in the document by exporting it to DXL and parsing that, and failing that, looping through the document’s items for all $FILE items.

I have one instance I am running across where, when I have an attachment that contains certain Unicode characters, cannot be found using GetAttachment. This document was able to export to DXL, and I’ve verified that the filename does contain the Unicode character.

I’ve changed the name of the file for privacy reasons, but the filename is:

“attachment(example).txt”

In this case, it may be hard to notice, but the opening parenthesis is not the standard parenthesis character. If I convert the character to it’s code, it ends up being 65288 (Hex code FF08). I also get this with closing parentheses, which are 65289 (Hex code FF09).

Calling GetAttachment with the filename as obtained from the DXL, after converting the Unicode characters to their ANSI counterparts, and by passing a Byte array containing the string all return Nothing. I checked the filename to verify that it isn’t stored as ATT#####, and it isn’t, it is stored as posted. And there are other attachments to the email without these Unicode characters and they extract fine.

Is there any way to get these attachments using GetAttachment or will I have to have a workaround for these attachments?

Thank you for your help.

Subject: RE: GetAttachment returns Nothing, Unicode in attachment name

I created a document (this document, actually), with a file attachment with the name you specified and the code below, and the output is “attachment(example).txt”. This was with version 8.0. Can you try this test in 6.5.5, in a memo you compose?

I suspect the problem is not with GetAttachment method, but with whatever you’re doing to get the filename from DXL. I don’t know what you mean by “converting the Unicode characters to their ANSI counterparts.” ANSI is not the name of a character set, and why would you do this? GetAttachment takes a Unicode argument.

Dim wksp As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Dim doc As NotesDocument

Dim ugblat

Set uidoc = wksp.CurrentDocument

On Error Resume Next ' this is just for the ND6/7 forum which gives an error if you use file attachments.

uidoc.Refresh True

On Error Goto 0

Set doc = uidoc.Document

ugblat = Evaluate("@AttachmentNames", doc)

Dim att As NotesEmbeddedObject

Set att = doc.GetAttachment(ugblat(0))

Print att.Name

Subject: RE: GetAttachment returns Nothing, Unicode in attachment name

What I mean by “converting the Unicode characters to their ANSI counterparts” is converting the Unicode parenthesis to the standard parenthesis you can find in the ANSI codepage, “(”. And I’m aware that the method takes a Unicode string, but as it couldn’t get this one file on this document, I had to try other methods, and I listed what I tried.

The thing is, on the document in question, the attachment has the same name from every source I try. Getting it from the DXL, doing Evaluate(“@AttachmentNames”, doc), looking at it in the Lotus Notes client, all of them give the same filename. And the attachment does exist, I can retrieve it from the document from the Lotus Notes client.

I can’t run your script. As I said in my original post, this is a Visual Basic 6 application. It’s not an agent written in LotusScript. Of the two references available for accessing Notes, one doesn’t allow me to create New instances of any of the Notes classes, and the other doesn’t contain native NotesUI objects, as they’re created through CreateObject, and won’t recognize a NotesUIDocument.Document being the same as a NotesDocument. And in my application, I don’t use the Lotus Notes UI, due to issues tied to closing UI documents causing Notes to crash.

When I extracted the attachment using the Lotus Notes client, preserving the filename with the Unicode parenthesis, and reattached it to a new Memo, I tried my method to get attachments, and it worked. So now I’m forced to think it’s tied to the document itself and not the attachment or attachment name.