Getting information from delegated email account from appointment inspector window - outlook 2013 using addin-express

馋奶兔 提交于 2019-12-13 05:51:12

问题


I am developing an Outlook plugin using add-in-express. There are two mail account (A) which has granted calendar access to account (B) through delegation. I am developing the plugin for account (B).

Here is what I want to implement.

I open the calendar account of (A) after login to outlook using the credentials of account (B) (as a user, not by C# code). Then double click on some date of the calendar, which leads to open a new inspector window for me. In the ribbon of the inspector, there is a button coming from my pluging. After user click the button, I need to show the email owner’s (account (A)) email and name in the body of the inspector.

Here is the code for the button

    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 = "\n\nOwner's Email\t: " + ownerEmail
                + "\nOwner's Name\t: " + 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();
        }
    }

Can you please advise me on this? Thank you.


回答1:


The Outlook object model doesn't provide anything for that. You may try to get the Store object and check its name (see the Store property of the Folder class). Typically the display name contains an email address (see DisplayName), but it is not a panacea.

I'd recommend using any low-level property viewer tool such as MFCMAPI or OutlookSpy. They allow observing low-level property values (as well as OOM) you may access using the PropertyAccessor class. Outlook is just a big wrapper around Extended MAPI.




回答2:


Try to read the PR_CreatorEmailAddr MAPI property (DASL name http://schemas.microsoft.com/mapi/proptag/0x4023001F) or a named property with GUID = {11000E07-B51B-40D6-AF21-CAA85EDAB1D0} (PSETID_CalendarAssistant) and ID = 0xA (DALS name http://schemas.microsoft.com/mapi/id/{11000E07-B51B-40D6-AF21-CAA85EDAB1D0}/000A001F) using AppointmentItem.PropertyAccessor.GetProperty.

What exactly will be available depends on the version of Exchange, Outlook, and on whether the delegate folders are cached. Take a look at an appointment in one of those folders with OutlookSpy (click IMessage) to see what is available.



来源:https://stackoverflow.com/questions/30911510/getting-information-from-delegated-email-account-from-appointment-inspector-wind

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!