I have a mail-in database application and I am finding that occasionally an email is received with an attachment that is not part of the Body field and therefor not able to be “seen” by rtItem.EmbeddedObjects.
How do I identify that there is an attachment if it is not in the Body and once I do that how do I get a handle on it?
I need to determine the type of attachment (PDF, JPG, DOC, XLS, etc.), detach it and then process it based on the extension.
Here is the various If statements that do all the checking of the Body (RTF) field and the associated EmbeddedObjects. This does not catch an attachment that is “outside” of the Body.
Set rtItem = mailDoc.Getfirstitem("Body")
If ( rtItem.Type = RICHTEXT ) Then
If Not (IsEmpty(rtItem.EmbeddedObjects)) Then
ForAll o In rtItem.EmbeddedObjects
If (o.Type = EMBED_ATTACHMENT) Then
noAttachment = True
Else
noAttachment = True
End If
End ForAll
Else
noAttachment = True
End if
Else
noRTF = True
End If
I also have a document with nothing in the Body but $File contains the attachment name. How do you find that?
Youll need to get at those attachments using the EmbeddedObjects property of the NotesDocument. The union of that property plus all the EmbeddedObjects properties of all rich text items gives you access to all the attachments. Note that usually you only need to worry about the Body rich text item.