0
votes

I am unable to retrive inline images/screen shot from Java in Lotus Notes from

document.getItemValueString('Body')

By above function am i able retrive text available in mailbody not inline images.

Please provide your suggestions in order to retrive inlines images from the mail body

Thanks in advance.

LSP Jyothi

1
Are you aware of the fact that Notes email messages can be in either of two formats, Notes rich text, and MIME? Do you need to work with both formats?Richard Schwartz

1 Answers

0
votes

First of all: Body is a NotesRichtextItem. You would have to use the NotesRichtextItem- methods and properties to get the inline- image... if there where any for that purpose.

Inline- images are not handled by any means in LotusScript. To get them, you need to:

  • Export the document as XML
  • Find the part in the XML that represents the inline image
  • take the Base64- encoded value there and convert it into a binary format, use Mime- Classes for that (Trick).
  • Write the data to a file

There is a lot of code involved in doing this. I just post the "crucial" parts of the code here (untested, no syntax check, just as a starting point):

EDIT: Sorry, I am not an expert in Java and only saw the tag "lotusscript", therefor my example is LotusScript- Code (should be similar with java, and I think Base64- operations are alreays built in in java, no need to use the Mime- Trick)

Dim strDxl as String
Dim strFoundBase64 as String
Dim exporter as NotesDXLExporter
Dim stream as NotesStream
Dim docConvert as NotesDocument
Dim mimeEntity as NotesMimeEntity
Set exporter = session.CreateDXLExporter
exporter.ConvertNotesBitmapsToGIF = True

strDxl = exporter.Export(document)

'- Search through strDxl and find everything that is in the following tags:
'- <gif></gif>, <gif originalformat='notesbitmap'></gif>, <jpeg></jpeg>, <png></png>
strFoundBase64 = ...'assign text between tags


'- use Mime class to convert to binary
Set docConvert = New NotesDocument( document.ParentDatabase )
Set mimeEntity = docConvert.CreateMIMEEntity
Call mimeEntity.SetContentFromBytes(strFoundBase64, "image/gif", ENC_BASE64)
'- Write result to file
Set stream = ses.CreateStream
Call stream.Open( "C:\Temp\image.gif", "binary")
Call mimeEntity.GetContentAsBytes(stream)
Call stream.Close()