I’m trying to save all attachments from a rich text field in Notes to the disk. Here’s my code:
Function varSaveAttachments(docBody As NotesDocument, strPath As String) As Variant
On Error GoTo ERRORHANDLER
Dim varRtItem As Variant
Dim varFilename As Variant
Dim intCounter As Integer
Dim strFileName As String
strPath = Replace(strPath, “/”, “_”)
Set varRtItem = docBody.Getfirstitem(“Body”)
If Not varRtItem Is Nothing Then
If varRtItem.Type = RICHTEXT Then
If Not IsEmpty(varRtItem.EmbeddedObjects) then
ForAll o In varRtItem.EmbeddedObjects
If o.Type = EMBED_ATTACHMENT Then
varFileName = Evaluate(“@AttachmentNames”, docBody)
For intCounter = 0 To UBound(varFileName)
strFileName = varFileName(intCounter)
strFileName = Replace(strFileName, “/”, “_”)
Call o.ExtractFile(strPath & "" & strFileName)
Next
End If
End ForAll
End If
End If
End If
At first this seems to work just fine. Every file in the rich text field is saved to disk, with the correct name.
However, when I open each file, they all contain the same contents as the very first file that is detached.
So if there are ten files in the rich text field, the first attachment is detached 10 times, but are given the the name of the 9 other attachments.
Anyone got any ideas?