gpt4 book ai didi

java - 如何使用 java 从 .nsf(lotus notes) 文件中获取所有附件

转载 作者:塔克拉玛干 更新时间:2023-11-01 22:15:39 25 4
gpt4 key购买 nike

遵循的步骤:

把我的莲花笔记背了一个作为sample.nsf

然后尝试从sample.nsf中读取附件

代码片段:

Database db = session.getDatabase("","C:\\Projects\\NotesToJava\\sample.nsf");
DocumentCollection dc = db.getAllDocuments();
Document doc = dc.getFirstDocument();

while (doc != null) {
RichTextItem body = (RichTextItem) doc.getFirstItem("Body");

if (body.getEmbeddedObject("Request.xlsx") != null)
System.out.println("Found BPM_Dev_Access_Request.xlsx in " + doc.getItemValueString("Subject"));

doc = dc.getNextDocument();
}

最佳答案

不需要使用evaluate,在Lotus Designer Help中查找extractFile

来自 Lotus 帮助:

import lotus.domino.*;
import java.util.Vector;
import java.util.Enumeration;
public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
// (Your code goes here)
Database db = agentContext.getCurrentDatabase();
DocumentCollection dc = db.getAllDocuments();
Document doc = dc.getFirstDocument();
boolean saveFlag = false;
while (doc != null) {
RichTextItem body =
(RichTextItem)doc.getFirstItem("Body");
System.out.println(doc.getItemValueString("Subject"));
Vector v = body.getEmbeddedObjects();
Enumeration e = v.elements();
while (e.hasMoreElements()) {
EmbeddedObject eo = (EmbeddedObject)e.nextElement();
if (eo.getType() == EmbeddedObject.EMBED_ATTACHMENT) {
eo.extractFile("c:\\extracts\\" + eo.getSource());
eo.remove();
saveFlag = true;
}
}
if (saveFlag) {
doc.save(true, true);
saveFlag = false;
}
doc = dc.getNextDocument();
}
} catch(NotesException e) {
System.out.println(e.id + " " + e.text);
e.printStackTrace();
}
}
}

关于java - 如何使用 java 从 .nsf(lotus notes) 文件中获取所有附件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7850189/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com