I am looking at an alterantive to GetAttachment(filename) of getting a handle on all attachments stored in a document - all in $FILE, not a RTF - and detach them to the file-system. The key thing is getting the handle on each attachment to be able to call the ExtractFile method?
Subject: RE: How to Extract All Attachments in a Document Held $File
You can still use NotesEmbeddedObject.
Instead of the NotesRichTextItem.EmbeddedObjects property, you can use NotesDocument.EmbeddedObjects property, which gets you the attachments even if they are not in a rich text field.
Subject: RE: How to Extract All Attachments in a Document Held $File
So, how do we detach all the files then?
Problem is that in some filenames we have Unicode characters which are not standard therefore the GetAttachment(filename) does not work for such files.
Somehow I therefore need to work out a means of extracting the file in $File without getting a handle on it using GetAttachment!
Subject: RE: How to Extract All Attachments in a Document Held $File
Wrong. You might want to read the Help entry a bit more closely – the EmbeddedObjects property of the NotesDocument includes attachments that are not associated with a rich text field. (We regularly use it in WQS agents to move attachments from the document to a particular rich text field.)
Subject: RE: How to Extract All Attachments in a Document Held $File
This is what I thought. It is really strange. I am finding it virtually impossible to extract the attachments that the GetAttachment method fails to return.
Is this as simple as Notes being unable to support the encoding/character set?
Subject: RE: How to Extract All Attachments in a Document Held $File
I believe that this is a case of badly written documentation. I.e., first it says:
“Note Embedded objects and object links are not supported for OS/2, UNIX, and the Macintosh. File attachments are.”
This implies that file attachments are returned by this property.
But then it says.
“Unlike the EmbeddedObjects property in NotesRichTextItem, this property does not include file attachments, nor OLE/1 objects created in Notes Release 3.”
Strictly as written, this implies that file attachments are not returned. But I believe that the qualification “created in Notes Release 3” really means “created in R3 or later inside rich text fields”, and that despite the positioning of the commas, that qualification was really intended to apply to file attachments in addition to OLE/1 objects. So what it really, really means is that NotesDocument.EmbeddedObjects doesn’t return attachments created inside an RTF, but does return attachments that are “below the line”.
Subject: RE: How to Extract All Attachments in a Document Held $File
Richard, Thank you for the clarification. I do agree that documentation is a bit confusing. So I looked at it again as Stan suggested(though I have looked at this documentation many times before). I also looked at the example at the end of which it states:
“EmbeddedObjects does not return the Ami Pro document because the object was created in Notes Release 3. It does not return castle.bmp because castle.bmp is a file attachment.”
So I wrote a quick code to check on documents submitted via web and I am not getting handle on any attachments below the line. I tested on Windows XP, R7 and R6. It might work work in WQS agents which I did not check. May be someone else can confirm.
Subject: RE: How to Extract All Attachments in a Document Held $File
That clearly indicates that HasEmbedded is returning true; and I believe that NotesDocument.HasEmbedded and NotesDocument.EmbeddedObjects are consistent with each other, so you should find the attachments in the EmbeddedObjects array, and we just need to work out why the forall isn’t working for you.
But to be honest, I think I’ve tried using forall before with EmbeddedObjects and had the same problem. It seems that all my current code working with EmbeddedObjects avoids using a forall, and looks more like this:
If rtf.hasEmbedded Then
Dim objects As Variant
objects = rtf.EmbeddedObjects
Dim i As Integer
For i = 0 To Ubound(objects)
Dim o As NotesEmbeddedObject
Set o = objects(i)
If o.Name = "something" Then
' do something
End If
Next
end if
Since I’m sure my preference would have been to use a forall, I think it must be that I faced the same problem you did and since nothing seemed obvious about why it didn’t work, I just switched to a regular for loop.
Subject: RE: How to Extract All Attachments in a Document Held $File
Well, that was just pulled from my code that does use the rtf. The point was just to show the alternative to forall. I expected you to modify it from using rtf to doc accordingly, and I expected it to not throw a type mismatch.
But if doc.HasEmbedded is true, while EmbeddedObjects is coming back as Nothing, then I have no clue.