使用Java API从Lotus Notes NSF文件中提取电子邮件 [英] Extracting email messages from a Lotus Notes NSF file using Java API

查看:583
本文介绍了使用Java API从Lotus Notes NSF文件中提取电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Java API(Notes.jar),并且正在运行装有Lotus Notes 8.5的Windows盒.

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

我对Lotus Notes一无所知,我只需要完成一项狭窄的任务:从NSF文件中提取电子邮件.我希望能够遍历所有电子邮件,获取元数据(发件人",收件人",抄送"等)或原始MIME(如果可用).

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.

我已经在Google上搜索了很多,但是我并没有发现任何简单的东西,而无需一些重要的Lotus Notes域专业知识.

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!

更新:我找到了一个在Python中执行此操作的开源项目:

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

http://code.google.com/p/nlconverter/

但是,仍在寻找用Java做到这一点的方法.

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

推荐答案

您可以编写一个简单的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();
      }
    }
}

getItemValueString方法获取给定的字段"值.邮件文档上的其他重要字段包括:发件人,发送至,CopyTo,BlindCopyTo,主题,正文和DeliveredDate.请注意,正文是Notes的富文本"项,getItemValueString将返回纯文本部分. DeliveredDate是一个NotesDate项,您需要为此使用getItemValueDateTimeArray方法.

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.

这篇关于使用Java API从Lotus Notes NSF文件中提取电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆