从约会检查器窗口获取委派电子邮件帐户的信息 - Outlook 2013 使用插件快递



我正在使用add-in-express开发一个Outlook插件。有两个邮件帐户 (A) 通过委派授予对帐户 (B) 的日历访问权限。我正在为帐户 (B) 开发插件。

这是我想要实现的。

登录 Outlook 后,我使用帐户 (B) 的凭据打开 (A) 的日历帐户(作为用户,而不是通过 C# 代码)。然后双击日历的某个日期,这将为我打开一个新的检查器窗口。在检查器的功能区中,有一个按钮来自我的插头。用户单击按钮后,我需要在检查器的正文中显示电子邮件所有者(帐户 (A))的电子邮件和姓名。

这是按钮的代码

    private void adxRibBtnDelegateTest_OnClick(object sender, IRibbonControl control, bool pressed)
    {
        Outlook.Inspector currentInspector = null;
        Outlook.AppointmentItem myAppointment = null;
        Outlook.MailItem myMailItem = null;
        string ownerEmail = string.Empty;
        string ownerName = string.Empty;

        try
        {
            currentInspector = Globals.ObjOutlook.ActiveInspector();
            myAppointment = currentInspector.CurrentItem as Outlook.AppointmentItem;
            myMailItem = currentInspector.CurrentItem as Outlook.MailItem;
            Outlook.AppointmentItem appt = currentInspector.CurrentItem as Outlook.AppointmentItem ;
            Outlook.MAPIFolder parent = appt.Parent as Outlook.MAPIFolder;
            // ToDo:
            // Here I need to develop the functionality for getting the delegated account owner's email and name
            string body = "nnOwner's Emailt: " + ownerEmail
                + "nOwner's Namet: " + ownerName;
            if (myAppointment != null)
            {
                myAppointment.Body = body;
            }
            else if (myMailItem != null)
            {
                myMailItem.Body = body;
            }
        }
        catch (Exception ex)
        {
            Debug.DebugMessage(2, "Error in AddNewNationalCall() : " + ex.Message);
        }
        finally
        {
            if (myAppointment != null) Marshal.ReleaseComObject(myAppointment);
            if (myMailItem != null) Marshal.ReleaseComObject(myMailItem);
            if (currentInspector != null) Marshal.ReleaseComObject(currentInspector);
            GC.Collect();
        }
    }

你能告诉我这个吗?谢谢。

Outlook 对象模型不提供任何内容。您可以尝试获取 Store 对象并检查其名称(请参阅 Folder 类的 Store 属性)。通常,显示名称包含电子邮件地址(请参阅显示名称),但它不是灵丹妙药。

我建议使用任何低级属性查看器工具,如MFCMAPI或OutlookSpy。它们允许观察可以使用 PropertyAccessor 类访问的低级属性值(以及 OOM)。Outlook 只是扩展 MAPI 的一个大包装器。

最新更新