I am extracting attachments in a document to user's local machine using LotusScript. The document has two rich text fields Body1
and Body2
and many a times only one of them has an attachment in it. I am using the below code snippet:
Dim doc As NotesDocument
Dim richTextItem As NotesRichTextItem
.....
.....
If doc.Hasembedded Then
Set richTextItem = doc.Getfirstitem("Body1")
ForAll o In richTextItem.Embeddedobjects
Call o.ExtractFile(dirName + "\" + o.Name)
End ForAll
Set richTextItem = doc.Getfirstitem("Body2")
ForAll o In richTextItem.Embeddedobjects
Call o.ExtractFile(dirName + "\" + o.Name)
End ForAll
End If
The problem is that if Body1
does not have attachment in it and Body2
does then the above code throws error of Type mismatch
on statement ForAll o In richTextItem.Embeddedobjects
and vice versa as there are no embedded objects in that rich text item. Also doc.Embeddedobjects
does not work because attachments are present inside rich text items. And the NotesRichTextItem
class does not have Hasembedded
property which can be used to check presence of attachments in it.
What would be a way out of this?