outlook-2013 – 在Outlook 2013中获取停靠的消息对象

获取当前打开的新电子邮件(从主Outlook窗口取消停靠时)需要以下代码:

Outlook.Application oApp = new Outlook.Application();
Outlook.Inspector inspector = oApp.ActiveInspector();
item = inspector.CurrentItem;
Outlook.MailItem oMsg = item as Outlook.MailItem;

当新邮件停靠在Outlook的主窗口中时,如何执行此操作?当用户单击他们当前正在查看的消息中的“回复”按钮时,会发生这种情况.

最佳答案 如果要将新消息作为对象(如Outlook.MailItem)返回,则应尝试以下操作:

Outlook.Application oApp = new Outlook.Application();
Outlook.MailItem oMsg = explorer.GetType().InvokeMember("ActiveInlineResponse",
    System.Reflection.BindingFlags.GetProperty |
    System.Reflection.BindingFlags.Instance |
    System.Reflection.BindingFlags.Public, null, explorer, null) as Outlook.MailItem;

您应该能够根据需要将文件附加到当前停靠的Outlook邮件.

点赞