Outlook 2013 加载项 - 电子邮件回复和转发"Popped in"窗口:界面类型是什么?


我一直在为 Outlook 2013

开发一个加载项,目前发现很难找到回复和转发电子邮件时出现在 Outlook 2013 中的"弹出"窗口的界面类型。

例如:对于新电子邮件,接口类型为 Outlook.MailItem,对于会议请求,接口类型为 Outlook.AppointmentItem。

我可以使用哪种界面类型来识别Outlook 2013中回复和转发时出现的弹出窗口?

当您回复或转发邮件项目时,新项目将是 MailItem 对象。您可以使用代码来确定项目类型:

        Object selObject = this.Application.ActiveExplorer().Selection[1];
        if (selObject is Outlook.MailItem)
        {
            Outlook.MailItem mailItem =
                (selObject as Outlook.MailItem);
            itemMessage = "The item is an e-mail message." +
                " The subject is " + mailItem.Subject + ".";
            mailItem.Display(false);
        }
        else if (selObject is Outlook.ContactItem)
        {
            Outlook.ContactItem contactItem =
                (selObject as Outlook.ContactItem);
            itemMessage = "The item is a contact." +
                " The full name is " + contactItem.Subject + ".";
            contactItem.Display(false);
        }
        else if (selObject is Outlook.AppointmentItem)
        {
            Outlook.AppointmentItem apptItem =
                (selObject as Outlook.AppointmentItem);
            itemMessage = "The item is an appointment." +
                " The subject is " + apptItem.Subject + ".";
        }
        else if (selObject is Outlook.TaskItem)
        {
            Outlook.TaskItem taskItem =
                (selObject as Outlook.TaskItem);
            itemMessage = "The item is a task. The body is "
                + taskItem.Body + ".";
        }
        else if (selObject is Outlook.MeetingItem)
        {
            Outlook.MeetingItem meetingItem =
                (selObject as Outlook.MeetingItem);
            itemMessage = "The item is a meeting item. " +
                 "The subject is " + meetingItem.Subject + ".";
        }

有关详细信息,请参阅如何:以编程方式确定当前 Outlook 项。

您也可以考虑检查 MailItem 类的 MessageClass 属性。属性将项链接到它所基于的窗体。选择项目后,Outlook 使用邮件类查找窗体并公开其属性,如"答复"命令。

我的经理和我坐在一起,解决了这个问题,谢天谢地,找到了解决方案。您可以使用以下代码访问"弹出"回复和转发窗口

//First, declare the interface type of Explorer
public static Outlook.Explorer currentExplorer;
//Create a method to identify the Inline response as a MailItem
    private void ThisAddIn_InlineResponse(object Item)
    {
        if (Item != null)
        {
            Outlook.MailItem mailItem = Item as Outlook.MailItem;
        }
    }
//Direct to the ThisAddIn_Startup() method and add an event handler for the Inline Response Method
currentExplorer.InLineResponse += ThisAddIn_InLineResponse;
//Access the popped in reply and forward window where required
object item = null;
item = currentExplorer.ActiveInlineResponse;

最新更新