notes java api,使用Java API从Lotus Notes NSF文件中提取电子邮件

I'd like to use the Java API (Notes.jar), and I'm running a Windows box with Lotus Notes 8.5 installed.

I know nothing about Lotus Notes, and I only need to do this one narrow task: extracting email messages from an NSF file. I want to be able to iterate through all the email messages, grab the metadata (From, To, Cc, etc) or the raw MIME if available.

I've googled around quite a bit, but I haven't found anything straightforward without requiring some significant Lotus Notes domain expertise.

Some sample code to get me started would be greatly appreciated. Thanks!

UPDATE: I found an open source project that does this in Python:

However, still looking for a way to do this in Java.

解决方案

You can write a simple Java app which gets a handle to the mail database you are interested in, then gets a handle to a standard view in that database, and then iterates over the documents in the view. Here is some (rough) sample code:

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 method gets a given "field" value. Other important fields on a mail document are: From, SendTo, CopyTo, BlindCopyTo, Subject, Body and DeliveredDate. Note that Body is a Notes "rich text" item, and getItemValueString will return the text-only portion. DeliveredDate is a NotesDate item, and you would need to use the getItemValueDateTimeArray method for that.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值