Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
462 views
in Technique[技术] by (71.8m points)

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

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 = "

Owner's Email	: " + ownerEmail
                + "
Owner's Name	: " + 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...