简体   繁体   中英

How to disable “New Email”-button on a folder change event in outlook 2016 using c#

Add-IN with a tab and toggle button, and a folderswitch event handler on add-in start up.

currentExplorer = this.Application.ActiveExplorer();
currentExplorer.FolderSwitch += new Outlook.ExplorerEvents_10_FolderSwitchEventHandler(CurrentExplorer_Event); 

I need to disable "New Email "-button on specific folder.
Can any one suggest me how to do this using c#?

The Fluent UI doesn't provide anything for disabling controls at runtime per conditions. However, you can try to rebuilt the entire ribbon UI from dcratch by using built-in idMso values. But I don't think that is a simple way to follow.

Instead, you may consider repurposing ribbon controls. See Temporarily Repurpose Commands on the Office Fluent Ribbon for more information.

The onAction attribute of the command element overrides the built-in functionality by pointing to a custom callback procedure. These procedures are called callbacks because when the button is clicked, the action alerts Microsoft Office that the control needs attention. Microsoft Office then calls back to the method defined by the onAction attribute and performs whatever action is contained in the method.

In the event handler (callback) of the repurposed control you can check the current folder and cancel the default action.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM