我正在开发一个JAVA应用程序,它通过JACOB Java Com Bridge从Outlook获取所有联系人。在Outlook中,有标准文件夹“Meine Kontakte”/“我的联系人”和相关的子文件夹“Kontakte”/“Contacts”。所以一切正常,我得到了所有的联系。但是当我创建另一个子文件夹时,例如“Test”,此文件夹中的联系人将不会显示在我的JAVA应用程序中。似乎只会获取默认文件夹中的联系人...但我需要所有联系人。有谁知道解决方案?
以下是代码:
final int olFolderContacts = 10;
contact = new Vector<Contact>();
ActiveXComponent ol = new ActiveXComponent("Outlook.Application");
@SuppressWarnings("unused")
Dispatch dsp = new Dispatch();
Dispatch olo = ol.getObject();
Dispatch myNamespace = Dispatch.call(olo, "GetNamespace", "MAPI")
.toDispatch();
Dispatch myFolder = Dispatch.call(myNamespace, "GetDefaultFolder",
new Integer(olFolderContacts)).toDispatch();
Dispatch items = Dispatch.get(myFolder, "Items").toDispatch();
int count = Dispatch.call(items, "Count").toInt();
for (int i = 1; i <= count; i++) {
Dispatch item;
item = Dispatch.call(items, "Item", new Integer(i)).toDispatch();
String fullName = Dispatch.get(item, "Fullname").toString();
String birthday = Dispatch.get(item, "Birthday").toString();
System.out.print(fullName);
DateFormat dateFormat = new SimpleDateFormat(
"EEE MMM dd HH:mm:ss Z yyyy");
Calendar cal_current = Calendar.getInstance();
// Calendar birthday !!!
Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat(
"EEE MMM dd HH:mm:ss Z yyyy", Locale.ENGLISH);
try {
cal.setTime(sdf.parse(birthday));
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
@SuppressWarnings("unused")
int monthCurrent = cal_current.get(Calendar.MONTH);
@SuppressWarnings("unused")
int month = cal.get(Calendar.MONTH);
....
答案 0 :(得分:0)
好的,这是解决方案。您必须调用特定的内部/子文件夹。 谢谢你的帮助!
Dispatch innerFolder = Dispatch.call(myFolder, "Folders","Test").toDispatch();