Search code examples
lotus-dominomimelotusscript

Reading MIME body of email


Traditional Domino design...db is mail-in database and receives emails from outside our domain. The resulting arrived memos are Multipart MIME-based emails. The documentation of NotesMIMEEntity seems pretty detailed but very little in the way of explaining or examples, etc.

I simply need to read the body of an incoming email to scrape items that are ultimately used in an agent set to run against newly arrived emails. The agent that does the scraping knows that the incoming email is bound by a template, so it knows what to find and retrieve.

How to get it is the problem. This is all new to me, mime entities and sibling entites and multiparts and boundaries...I am hoping someone has examples or can point me to an article detailing how to read this content. I just want the body as plain text.


Solution

  • You can let Domino convert the MIME content to Rich Text and then read contents from the Rich Text field.

    Try something like this (not tested):

    Dim rtitem As NotesRichTextItem
    Dim plainText As String
    
    notesSession.ConvertMIME = false
    Set rtitem = doc.GetFirstItem("Body")
    plainText = rtitem.GetFormattedText( False, 0 )
    notesSession.ConvertMIME = true