We can check the rich text field for attachments before looping for all the attachments in RT field. To check the rich text field we can use “IsEmpty” function.We can not user “IsNull” function.
Dim doc As NotesDocument
Dim rtitem As Variant
'…set value of doc…
Set rtitem = doc.GetFirstItem( “Body” )
If ( rtitem.Type = RICHTEXT ) Then
attachexist = rtitem.EmbeddedObjects
If Isempty(attachexist) = False Then
Forall o In rtitem.EmbeddedObjects
If ( o.Type = EMBED_ATTACHMENT ) Then
Call o.ExtractFile( "c:\samples\" & o.Source )
Call o.Remove
Call doc.Save( False, True )
End If
End Forall
End If
End If