I am trying to create an Excel VBA macro that accesses the email documents of a Lotus Notes mailbox.
The following code checks the type of the "Body"
NotesItem
and whether NotesDocument.GetMIMEEntity()
works after getting the NotesDocument
with Session.ConvertMime
set to True
and to False
.
Sub Test()
Dim Session As NotesSession, DB As NotesDatabase, Doc As NotesDocument
Set Session = GetSession("xxx")
Set DB = Session.GetDatabase("", "yyy")
Session.ConvertMime = False
Set Doc = DB.AllDocuments.GetFirstDocument
Debug.Print TypeName(Doc.GetFirstItem("Body")), Doc.GetMIMEEntity Is Nothing
Session.ConvertMime = True
Set Doc = DB.AllDocuments.GetFirstDocument
Debug.Print TypeName(Doc.GetFirstItem("Body")), Doc.GetMIMEEntity Is Nothing
Debug.Print TypeName(Doc.CreateMIMEEntity("Body2"))
End Sub
I was expecting to get this result:
IMIMEEntity False
IRichTextItem True
IMIMEEntity
Instead I get this:
IRichTextItem True
IRichTextItem True
IMIMEEntity
Are you REALLY sure, that the very first document in your database "AllDocuments" collection is a MIME Mail?
The "ConvertMime"- parameter is only relevant if there is MIME to convert. But mails can be completely NRPC routed and never converted to MIME. With default settings EVERY mail coming from one native Notes user using the Notes client going to another Notes user will be NotesRichtext and NOT Mime...
So: Your expectations are wrong for a large bunch of mails in a "normal" Notes/Domino environment.