[英]Get .txt file from Lotus Notes document using Java
I created the notes doument using java code and then created the rich text field as follow 我使用Java代码创建了便笺本,然后按如下所示创建了富文本字段
doc = db.createDocument();
doc.replaceItemValue("FROMMAIL", "sender@gmail.com");
doc.replaceItemValue("SENDTO", "receiver@gmial.com");
doc.replaceItemValue("SUBJECT", "NotesSlrWriter");
DateTime s2 = sess.createDateTime(new Date());
System.out.println("Setting date to: "
+ s2.toJavaDate().toLocaleString());
doc.replaceItemValue("POSTEDDATE", s2);
RichTextItem t = doc.createRichTextItem("Attachements");
t.appendText("Here is the Attachment");
t.addNewLine(2);
t.embedObject(EmbeddedObject.EMBED_ATTACHMENT, null,
"c:\\test\\test.txt", "testtxt");
doc.save();
So i know from using doc.getItemValue(arg0) values i can get the values of the other field in my java code. 所以我知道通过使用doc.getItemValue(arg0)值,我可以获取Java代码中其他字段的值。
But i don't know how i can get test.txt in a Attachment field of Notes Document into my java class 但是我不知道如何在Notes文档的Attachment字段中将test.txt放入Java类
In case if you do not know the file name, you can walk through all attachments in RichTextItem. 如果您不知道文件名,则可以遍历RichTextItem中的所有附件。
Below is example that scan 1 richtextitem and export all files in folder. 下面是扫描1个richtextitem并导出文件夹中所有文件的示例。
RichTextItem body = doc.getFirstItem("Attachements");
Vector v = body.getEmbeddedObjects();
Enumeration e = v.elements();
while (e.hasMoreElements()) {
EmbeddedObject eo = (EmbeddedObject)e.nextElement();
if (eo.getType() == EmbeddedObject.EMBED_ATTACHMENT) {
System.out.println("\t" + eo.getName());
eo.extractFile("c:\\extracts\\" + eo.getSource());
eo.remove();
}
}
There is another solution, that may help you: 还有另一种解决方案,可以帮助您:
EmbeddedObject eo = doc.getAttachment("testtxt");
System.out.println(eo.getName());
eo.extractFile("c:\\extracts\\" + eo.getSource());
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.