I am attempting to add a custom button which launches my macro to the context menu when right clicking an email. I am doing this in my work environment and don't have access to anything other than vanilla Outlook and VBA. I can't create an add-on or use an XML editor or other development program.
I am trying to edit the the officeUI file directly using Notepad. I know this works for ribbon buttons (though I have just added them using the ribbon customisation function in Outlook anyway).
So far my XML looks like this (forgive the lack of indenting, I'm using Notepad):
<mso:cmd app="olkexplorer" dt="1" />
<mso:customUI xmlns:x1="http://schemas.microsoft.com/office/2009/07/customui/macro" xmlns:mso="http://schemas.microsoft.com/office/2009/07/customui">
<contextMenus>
<contextMenu idMso="ContextMenuMailItem">
<button id="MyButton2" label="My Button 2" insertBeforeMso="Copy" onAction="Project1.GetButtonID" visible="true" />
<button id="MyButton2asdf" label="My Basutton 2" insertBeforeMso="Reply" onAction="Project1.GetButtonID" visible="true" />
</contextMenu>
</contextMenus>
<mso:ribbon>
<mso:qat/>
<mso:tabs>
<mso:tab idQ="mso:TabMail">
<mso:group...>
<mso:button...>
</mso:group>
</mso:tab>
</mso:tabs>
</mso:ribbon>
</mso:customUI>
Everything except for the context menu part is the original file after I created some macro buttons in the ribbon.
I have tried:
mso:
after <
on each line.id
, idQ
, and idMso
.mso:
before ContextMenuMailItem
I'm all out of ideas. If anyone had any suggestions or could post their own working officeUI file with context menu additions, I would be very appreciative!
After looking more into it, I've come to the conclusion that the customization of the Context Menu in Outlook is not possible by editing .officeUI
file.
Normally, to customize the Outlook UI, one would need to edit the file named olkexplorer.officeUI
located in C:\Users\%username%\AppData\Local\Microsoft\Office
as you are currently doing1.
However, I tried to play around with the <mso:contextMenus>
section and couldn't make it work. As soon as this tag is present in the XML file and I restart Outlook, I lose all customizations. This tells me that the tag is causing some parsing error as it's not supported.
Looking at the documentation for MS-CUSTOMUI, they don't even mention Outlook which indicates that there is no guarantee that Outlook would support features detailed there.
An Outlook MVP also confirms here that it's not possible to customize the Context Menu (aka. right-click menu). I'm assuming that they meant "not possible using the Outlook UI" since we know that it's possible via a VSTO add-in.
In Excel, you can use the CommandBarControls.Add method to add an element to a Context Menu, but this feature was removed in Outlook 2013 as discussed here.
From Microsoft's documentation on the Fluent API:
To programmatically customize the UI in Outlook, you must write an add-in.
See also this question and this question.
1: However, I don't think you need to have the first line with <mso:cmd app="olkexplorer" dt="1" />
. This is something that you get when exporting the ribbon customizations from the interface as a .exportedUI
file, but it shouldn't play a role in the .officeUI file