5

I have an Outlook 2010 addin, and I'm trying to create a custom context menu item. Whenever the user is in the Message body and right clicks, I would like to have my addin do some action on the selected text. I have a Ribbon bar that already has the actions I want, But I have no idea how to actually create the context menu item. I've found a couple tutorials for MailItems, but they do not seem to work within the message body. I do not want to use IContextMenuDisplay, because it is deprecated.

Can anyone be of assistance?

I've found:

http://www.developerzen.com/2005/04/04/adding-a-button-to-outlooks-context-menu/ http://weblogs.asp.net/avnerk/archive/2007/01/03/vsto-for-outlook-2007-building-the-add-in-part-2.aspx http://www.roelvanlisdonk.nl/?p=1184

Edit: I've realized that the message body is using the Word context menu, is this possible with word?

Shane Chin
  • 578
  • 2
  • 9
  • 20

1 Answers1

5

Use this as your custom context menu xml. I was confused because the idMso needed for the message body is ContextMenuText, instead of those dealing with outlook mailitems.

<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
 <contextMenus>
<contextMenu idMso="ContextMenuText">
  <button idMso="FontDialog" visible="false" />
  <toggleButton id="MyToggle" label="My Toggle Button" />
  <button id="MyButton" label="My Button" insertBeforeMso="HyperlinkInsert" onAction="GetButtonID" />
  <menuSeparator id="MySeparator" />
  <menu id="MySubMenu" label="My Submenu" >
    <button id="MyButton2" label="Button on submenu" />
  </menu>
  <gallery id="galleryOne" label="My Gallery">
    <item id="item1" imageMso="HappyFace" />
    <item id="item2" imageMso="HappyFace" />
    <item id="item3" imageMso="HappyFace" />
    <item id="item4" imageMso="HappyFace" />
  </gallery>
  <dynamicMenu id="MyDynamicMenu" label= "My Dynamic Menu" getContent="GetMyContent" />
</contextMenu>
</contextMenus>
</customUI>
Shane Chin
  • 578
  • 2
  • 9
  • 20
  • 1
    I was struggling with this for a couple of days, thanks a ton for unblocking me!!! – Sanket Jul 30 '11 at 00:17
  • 1
    That was really helpful for me as well ^_^ Thank you! Do you know where you can find more info about all context menus and their respective idMso? Being drilling down at MSDN but haven't been able to locate them yet :) – Vintharas Oct 10 '11 at 11:32