我希望能够将Outlook消息拖放到浏览器中并触发Javascript事件,例如,使用消息的GUID创建指向消息的链接。
但是我停留在第一步-尝试将Outlook消息拖到文件夹列表之外的任何位置都会显示不允许的光标。
我打算放弃,除了我发现一些帖子建议启用该操作的方法,例如如何将电子邮件从Outlook拖放到Java应用程序中?
有什么办法可以做到这一点? (尽管不理想,但包括编写浏览器扩展。)
public void drop(DropTargetDropEvent arg0) {
// TODO Auto-generated method stub
try {
// get the object that is being transferred
ActiveXComponent ol = new ActiveXComponent("Outlook.Application");
Dispatch explorer = Dispatch.get(ol, "ActiveExplorer").toDispatch();
Dispatch selection = Dispatch.get(explorer, "Selection").toDispatch();
Variant count = Dispatch.get(selection, "Count");
for (int mailIndex = 1; mailIndex <= count.getInt(); mailIndex++) {
Dispatch mailItem = Dispatch.call(selection, "Item", new Variant(mailIndex)).toDispatch();
Variant subject = Dispatch.get(mailItem, "Subject");
Variant received = Dispatch.get(mailItem, "ReceivedTime");
Variant cc = Dispatch.get(mailItem, "Cc");
Variant to = Dispatch.get(mailItem, "To");
Variant body = Dispatch.get(mailItem, "Body");
_contactEmailId.setText(to.getString());
_ccList.setText(cc.getString());
_subject.setText(subject.getString());
_body.setText(body.getString());
System.out.println("Subject : " + subject);
System.out.println("Received :" + received);
System.out.println("To :" + to);
System.out.println("Cc :" + cc);
System.out.println("Body Content :" + body);
Dispatch attachments = Dispatch.get(mailItem, "Attachments").toDispatch();
Variant count1 = Dispatch.get(attachments, "Count");
String directory = System.getProperty("java.io.tmpdir");
int numberOfAttach = count1.getInt();
if (numberOfAttach > 1) {
for (int i = 1; i <= numberOfAttach; i++) {
Dispatch attachment = Dispatch.call(attachments, "Item", new Variant(i)).toDispatch();
// get the name of the file
Variant nameOfFile = Dispatch.get(attachment, "DisplayName");
String fileName = directory + "/" + nameOfFile.getString();
Variant saveEmail = Dispatch.call(attachment, "SaveAsFile", fileName);
}
}
}
}
catch (Exception e) {
e.printStackTrace();
}
}