我想使用 Java API (Notes.jar),并且正在运行安装了 Lotus Notes 8.5 的 Windows 机器。
我对 Lotus Notes 一无所知,我只需要完成一项狭窄的任务:从 NSF 文件中提取电子邮件。我希望能够遍历所有电子邮件,获取元数据(发件人、收件人、抄送等)或原始 MIME(如果可用)。
我在 google 上搜索了很多,但没有找到任何不需要一些重要的 Lotus Notes 领域专业知识的简单方法。
一些帮助我入门的示例代码将不胜感激。谢谢!
更新:我发现一个开源项目可以在Python中执行此操作:
http://code.google.com/p/nlconverter/ http://code.google.com/p/nlconverter/
然而,仍在寻找一种在 Java 中执行此操作的方法。
您可以编写一个简单的 Java 应用程序,它获取您感兴趣的邮件数据库的句柄,然后获取该数据库中标准视图的句柄,然后迭代视图中的文档。这是一些(粗略的)示例代码:
import lotus.domino.*;
public class sample extends NotesThread
{
public static void main(String argv[])
{
sample mySample = new sample();
mySample.start();
}
public void runNotes()
{
try
{
Session s = NotesFactory.createSession();
Database db = s.getDatabase ("Server", "pathToMailDB.nsf");
View vw = db.getView ("By Person"); // this view exists in r8 mail template; may need to change for earlier versions
Document doc = vw.getFirstDocument();
while (doc != null) {
System.out.println (doc.getItemValueString("Subject"));
doc = vw.getNextDocument(doc);
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
The getItemValueString
方法获取给定的“字段”值。邮件文档中的其他重要字段有:From、SendTo、CopyTo、BlindCopyTo、Subject、Body 和 DeliveredDate。请注意,Body 是 Notes“富文本”项目,并且getItemValueString
将返回纯文本部分。 DeliveredDate 是一个 NotesDate 项目,您需要使用getItemValueDateTimeArray
方法。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)