0

I am trying to read the emails from NSF file. I want to fetch the inline images from the email body. But I am getting value as a text only

Here is my sample code.

          _lotesNotesSession.ConvertMime = false;

           nDB      =  _lotesNotesSession.GetDatabase(null, path, false);

           nView    =  nDB.GetView("$Inbox");

           nDoc     =  nView.GetFirstDocument();

           NotesMIMEEntity nMime = nDoc.GetMIMEEntity("Body");

How can I get the HTML Body of the emails?

Regards; Mayuresh.

Mayuresh
  • 423
  • 1
  • 6
  • 24

2 Answers2

1

You need to read the documentation of the NotesMIMEEntity class. A MIME entity may have child and sibling entities, which includes images. You are going to have to write code that examines the ContentType and ContentSubType properties to determine whether it has children (i.e. multipart), and then use the getFirstChildEntity, getNextSibling and getNextEntity methods to walk the tree of entities to find the images by checking ContentType and ContentSubType for each entity. Then you will need to examine the Encoding property of the entity containing the image to determine how the image is represented, then use the contentAsText property to get the encoded content and write (or find) code to decode the text into the binary image.

Richard Schwartz
  • 14,463
  • 2
  • 23
  • 41
  • For some emails I am not getting NotesMimeEntity nMime = nDoc.GetMIMEEntity("Body"); returns null – Mayuresh Aug 08 '16 at 06:48
  • Notes and Domino handle two mail formats: Notes rich text, and MIME. An easy way to test is to check for hasItem("$NoteHasNativeMIME"). If the messages is rich text, you cannot use the MIME classes, but there are techniques that you can use to turn the message into a MIME and then access the message. See this earlier question on StackOverflow for more info: http://stackoverflow.com/questions/1880511/how-to-export-rich-text-fields-as-html-from-notes-with-lotusscript – Richard Schwartz Aug 08 '16 at 13:08
0

First of all, a document can have multiple Body fields, is you may not be getting the field with the image in it. In addition, the image may be stored as MIME (which is text). If not, you'll need to look for the images elsewhere in the document and work with those. They could be as embedded objects or in $File fields.

Duston
  • 1,601
  • 5
  • 13
  • 24