Daryl
Daryl

Reputation: 15

Lotus Notes: Displaying Image attachment on a document

I have a field (Rich Text), that holds the value of an image attachment, but it only display the image path and filename, not as an image display. Am I using the wrong field or there's a problem in my line of code to attach the image? The code to attach is right below:

chqRSIDoc.photodoc = workspace.Openfiledialog(True, "Select a file to attach as photo: ", "", "c:\")

Appreciate all the help. Thanks!

Upvotes: 0

Views: 2403

Answers (2)

umeli
umeli

Reputation: 1068

Here's an example in Java

Stream stream = this.session.createStream();
            MIMEEntity body = doc.createMIMEEntity("dummy");
            MIMEHeader header = body.createHeader("Content-type");
            header.setHeaderVal("multipart/mixed");
            MIMEEntity child = body.createChildEntity();
            if (stream.open(filePath))
            {
                child.setContentFromBytes(stream, "image/jpeg", 1730);
                stream.close();
                doc.save(true, false);
                if (doc.hasItem("Body"))
                {
                    doc.removeItem("Body");
                }
                RichTextItem rt1 = doc.createRichTextItem("Body");
                RichTextItem rt2 = (RichTextItem) doc.getFirstItem("dummy");
                rt1.appendRTItem(rt2);
                rt2.remove();
                doc.save(true, false);
                recycle(rt2, rt1, child, header, body);
            }

Upvotes: 0

umeli
umeli

Reputation: 1068

The openFileDialog returns just a string array. see http://www.ibm.com/support/knowledgecenter/SSVRGU_9.0.0/com.ibm.designer.domino.main.doc/H_OPENFILEDIALOG_METHOD_5310_ABOUT.html
I assume thatyour chqRSIDoc is of NotesDocument. If you want it as an attachment you'll have to use the NotesRichTextItem.EmbedObject function.

Upvotes: 1

Related Questions