Putting Image in richtext field using NoteMimeEntity

Hi All,I have an image in my local drive “C:\Lotus\temp\0808100001.gif”

i want to put it in richtext field “RT_Picture” in form frmsafety using NotesMimeEntity Code.

I used this code, but image is not displaying in richtext field “RT_Picture”

            Dim s As New NotesSession

Dim ws As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Dim db As NotesDatabase

Dim doc As NotesDocument

            Dim nsess As New NotesSession

Dim RTImage As NotesMimeEntity

Dim nsIn As NotesStream



Set db=s.CurrentDatabase

Set uidoc= ws.CurrentDocument

Set doc=uidoc.Document

            Set RTImage = doc.CreateMIMEEntity("RT_Picture" )

           Set nsIn = nsess.CreateStream

           Call nsIn.Open( "C:\Lotus\temp\0808100001.gif" )

           Call RTImage.SetContentFromBytes (nsIn, "image/gif",   ENC_NONE)

I am not able to findout the error with the code.

Please help and provide the code.

Thanks.

Subject: Putting Image in richtext field using NoteMimeEntity

I am rather sure that you MUST save the background doc and then close UI doc it and open again in UI in order to see the image.

Not sure if your particular code works, otherwise you can try 3rd part tools or DXL import.

Subject: RE: Putting Image in richtext field using NoteMimeEntity

There is no imgae saving in background.I have a form with 2 fields

  1. “Rt_Picture” which is richtext field

  2. “Safety_No” which is a text field.

I wrote the code on exit event of field “safety_No”

to put the image in “Rt-Picture” without closing uidoc.

Subject: RE: Putting Image in richtext field using NoteMimeEntity

You can not show new picture in Rt_Picture field in UI without saving (in background) and re-opening(in UI) the document. Make sure to not save in UI after saving in background as it will rewrite your background changes.

From help file: Modifications made to rich-text items on the back-end document do not appear on the current document until it is closed and reopened.

You should however be able to use Import function without re-opening the document:

Dim workspace As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Call uidoc.GotoField(“Body”)

Call uidoc.Import(“GIF Image”, “c:\tmp\mypic.gif”)

/Andrei

http://dominounlimited.blogspot.com

Subject: RE: Putting Image in richtext field using NoteMimeEntity

I agree with Andrei that uidoc.Import is your best choice in this case.

However, I disagree that you have to save the document to make back-end changes to appear. You can close and reopen without saving. See the Update rich text tip. I don’t recommend that for this application, but it’s good to know that it’s possible.

Or, if you have a limited set of images, you can make them image resources, and use a formula to display the appropriate one by just refreshing the window.

Subject: If Import Image 2 Lotus Notes is an option, you can use the ProcessImage function …

…to do all your image modifications (convert image formats etc, resize then, overlay text or images etc etc) and then use the uidoc.Import function to import the image into an unsaved Notes document.

Subject: If an thirs-part solution is an option, you can check out Import Image 2 Lotus Notes …

With II2LN you can import almost any image format to richtext fields with a couple of LotusScript-lines…

Check out Voith's CODE :: Import Image 2 Lotus Notes if you are interested.

Bob, author of II2LN