Lotus Notes: Displaying Image attachment on a document

拟墨画扇 提交于 2019-12-11 19:15:38

问题


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!


回答1:


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.




回答2:


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);
            }


来源:https://stackoverflow.com/questions/36464607/lotus-notes-displaying-image-attachment-on-a-document

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!