总结见文章最后,具体代码如下:
ActiveXComponent outlook = new ActiveXComponent("Outlook.Application");
Dispatch myNamespace = Dispatch.call(outlook, "GetNamespace", "MAPI").toDispatch();
//指定搜索特定的文件
Dispatch allFolders = Dispatch.call(myNamespace, "Folders", "lixxxx@ccccc.com").toDispatch();
Dispatch myFolder = Dispatch.call(allFolders, "Folders", "我的文件夹").toDispatch();
Dispatch items = Dispatch.get(myFolder, "Items").toDispatch();
int count = Dispatch.call(items, "Count").toInt();
for (int x = count; x >= count-5; x--) {
Dispatch sMail = Dispatch.call(items, "Item", new Integer(x)).toDispatch();
Variant vSubj = Dispatch.get(sMail, "Subject");
Variant receivedTime = Dispatch.get(sMail, "ReceivedTime");
Variant senderName = Dispatch.get(sMail, "SenderName");
String subj = vSubj.getString();
if(senderName.getString().contains("more")){
Dispatch.call(sMail, "Delete");
return;
}
}
所以,找到item,然后使用Dispatch.call(item, “Delete”)即可
todo
清空回收站