Extracting attachments from RT

I have a database that has 3 RT fields. Any of the fields could have attachments, but they could also have images, text, etc. along with the attachments in the same fields. I need to extract all of the attachments and save them to disk. I’ve tried looping thru the documents and checking the rtitems to see if they were of the type EMBED_ATTACHMENT and then using the ExtractFile method, but it seems to fail on documents where there’s mixed content.

Any ideas or code samples anyone can provide? I appreciate any assistance. Thank you.

Subject: Extracting attachments from RT

If you simply get the NotesDocument and check the

notesDocument.EmbeddedObjects

that will have all the attachments without any of the images, text, doclinks, etc. Look at the help for EmbeddedObjects and I bet there is evan an example you can use.

Subject: RE: Extracting attachments from RT

From the Help about this property it says: “Unlike the EmbeddedObjects property in NotesRichTextItem, this property does not include file attachments…”

If this is the case, how can I use it to extract file attachments? Maybe I’m misunderstanding.

Subject: RE: Extracting attachments from RT

Another way, no so neat perhaps, is to use the Evaluate function and the @Formula @AttachmentNames.

It will return each and every attachment in the document, whether in a richtext-item or not.

Essentially what you get is the same as the $FILE items.

The problem is that embedded objects will be returned as well (I’m not sure about the images).

If you know that all attachments have proper file extensions, you can loop through the set returned from the Evaluate-function and check the name.

Example:

Dim vAttachments As Variant

vAttachments = Evaluate(“@AttacmentNames”, doc)

Forall v In vAttachments

If v <> “” Then

… do something…perhaps getAttachments and/or extractfile

End If

End Forall