如何在java中使用JACOB.jar从outlook读取邮件?

时间:2014-10-20 07:19:57

标签: java jacob

我正在使用JACOB.jar来访问outlook。我正在计算我的收件箱邮件和每个电子邮件会话ID。任何人都可以帮我找到如何使用jacob.jar

阅读outlook中的每封邮件
package com.cicada.stratos.etc;
import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.*;
public class OutLook {
public static void main(String[] args)
{
ActiveXComponent ol = new ActiveXComponent("Outlook.Application");
Dispatch dsp = new Dispatch();
Dispatch olo = ol.getObject();
Dispatch myNamespace = Dispatch.call(olo, "GetNamespace","MAPI").toDispatch();
Dispatch myFolder = Dispatch.call((Dispatch) myNamespace,"GetDefaultFolder", new      Integer(6)).toDispatch();
Dispatch items = Dispatch.get(myFolder, "Items").toDispatch();
Dispatch mails = Dispatch.get(myFolder, "Items").toDispatch();

int count = Dispatch.call(items, "Count").toInt();
System.out.println("Totl Msg Count"+count);
for (int i = 1; i <= count; i++)
{
Dispatch item;
item = Dispatch.call(items, "Item", new Integer(i)).toDispatch();
String msg = item.toString();


System.out.println(msg);
//System.out.println(msgs);

}
}
}

0 个答案:

没有答案