Write contents of InputStream to a RichTextItem and attach to a Notes document in Java

本小妞迷上赌 提交于 2019-12-06 08:14:27

Via the JAVA API (or LotusScript, COM) I don't see a way to add an attachment to a rich text item using anything but the embedObject method. And unfortunately the embedObject method only takes a string pointing to the file location to be imported. Without a way to pass in an actual object it seems you are required to have the file on disk and pass the path to that file.

ranjan

I actually found solution for my question. Maybe it will be helpful for someone

attachDocument(InputStream is){
        .....
        //File attFile = saveInputStr(is);
        Document attdoc = testdb.createDocument();
        attDoc.replaceItemValue("Form", "formAttachment");
        //RichTextItem rti = (RichTextItem) attDoc.getFirstItem("attachment");
        //rti.embedObject(EmbeddedObject.EMBED_ATTACHMENT, "", attFile .getPath(), attFile .getName());
        attDoc.getFirstItem("attachment");
        Stream stream = DominoUtils.getCurrentSession().createStream();
        stream.write(IOUtils.toByteArray(is));
        MIMEEntity me = attDoc.createMIMEEntity("attachment"); 
        me.setContentFromBytes(stream, "application/pdf", MIMEEntity.ENC_IDENTITY_8BIT);
        is.close();
        attdoc.save();
        .....
    }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!