none
[VSTO outlook] idMso for menu when right click on a contact RRS feed

  • Question

  • What's the idMso of the contact menu ?

    I checked the list in the excel documents: https://www.microsoft.com/en-us/download/details.aspx?id=50745

    but I couldn't find it 

        <contextMenu idMso="???????">
          <button id="orgChartMenuBtn"
              label="get info"
              onAction="lookForMe"
              visible="true"/>
        </contextMenu>

    and how can I get the value selected ?

            public void lookForMe(IRibbonControl control)
            {
                var item = control.Context as Inspector;
                if (item != null){                
                    var mailItem = item.CurrentItem as MailItem;
                    System.Diagnostics.Process.Start("https://org.ad.com/" + mailItem);
                }                
            }


    Tuesday, April 2, 2019 5:09 PM

Answers

  • Hi @Wendy

    thank you for your concern 

    I found the idMso is ContextMenuContactCardRecipient

    And we can get the address:

            public void lookForMe(IRibbonControl control)
            {
                Office.IMsoContactCard card = control.Context as Office.IMsoContactCard;
                string email = GetSmtpAddress(card);
                if (email != null)
                {
                    System.Diagnostics.Process.Start("https://org.ad.com/" + email);
                }
            }
    
            private string GetSmtpAddress(Office.IMsoContactCard card)
            {
                if (card.AddressType == Office.MsoContactCardAddressType.msoContactCardAddressTypeOutlook)
                {
                    Microsoft.Office.Interop.Outlook.Application host = Globals.ThisAddIn.Application;
                    Microsoft.Office.Interop.Outlook.AddressEntry ae = host.Session.GetAddressEntryFromID(card.Address);
    
                    if ((ae.AddressEntryUserType == Microsoft.Office.Interop.Outlook.OlAddressEntryUserType.olExchangeUserAddressEntry 
                        || ae.AddressEntryUserType == Microsoft.Office.Interop.Outlook.OlAddressEntryUserType.olExchangeRemoteUserAddressEntry))
                    {
                        Microsoft.Office.Interop.Outlook.ExchangeUser ex = ae.GetExchangeUser();
                        return ex.PrimarySmtpAddress;
                    }
                    else
                        throw new System.Exception("unvalid address entry not found.");
                }
                else
                    return card.Address;
            }


    • Marked as answer by Zero0o Wednesday, April 3, 2019 2:32 PM
    • Edited by Zero0o Friday, April 5, 2019 9:19 PM
    Wednesday, April 3, 2019 2:32 PM

All replies

  • Hi Zero0o,

    Thank you for posting here.

    Since your question is more related to VSTO, you could post a new thread in VSTO forum.

    The Visual C# forum discuss and ask questions about the C# programming language, IDE, libraries, samples, and tools.

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, April 3, 2019 3:10 AM
  • Hi @Wendy

    thank you for your concern 

    I found the idMso is ContextMenuContactCardRecipient

    And we can get the address:

            public void lookForMe(IRibbonControl control)
            {
                Office.IMsoContactCard card = control.Context as Office.IMsoContactCard;
                string email = GetSmtpAddress(card);
                if (email != null)
                {
                    System.Diagnostics.Process.Start("https://org.ad.com/" + email);
                }
            }
    
            private string GetSmtpAddress(Office.IMsoContactCard card)
            {
                if (card.AddressType == Office.MsoContactCardAddressType.msoContactCardAddressTypeOutlook)
                {
                    Microsoft.Office.Interop.Outlook.Application host = Globals.ThisAddIn.Application;
                    Microsoft.Office.Interop.Outlook.AddressEntry ae = host.Session.GetAddressEntryFromID(card.Address);
    
                    if ((ae.AddressEntryUserType == Microsoft.Office.Interop.Outlook.OlAddressEntryUserType.olExchangeUserAddressEntry 
                        || ae.AddressEntryUserType == Microsoft.Office.Interop.Outlook.OlAddressEntryUserType.olExchangeRemoteUserAddressEntry))
                    {
                        Microsoft.Office.Interop.Outlook.ExchangeUser ex = ae.GetExchangeUser();
                        return ex.PrimarySmtpAddress;
                    }
                    else
                        throw new System.Exception("unvalid address entry not found.");
                }
                else
                    return card.Address;
            }


    • Marked as answer by Zero0o Wednesday, April 3, 2019 2:32 PM
    • Edited by Zero0o Friday, April 5, 2019 9:19 PM
    Wednesday, April 3, 2019 2:32 PM