How to hide/disable send button in Outlook 2007

  • Thread starter jubergolandaj
  • Start date Views 3,768
J

jubergolandaj

#1
I am working on Outlook 2007 Add-in developed in C# and VS-2008. In this we

are having our own custom form .oftOn this form we have our custom "Send"

button on click event of it our processing continues. Now the problem we are

facing is we want to disable or hide the built-in send button of Outlook on

the Ribbon. Also we want to disable or hide some groups in the Tabs on

Ribbon. We have tried to do this by using custom Ribbon class implementing

Office.Core.IRibbonExtensibility interface.In ThisAddin file we have written

the following method: protected override

Microsoft.Office.Core.IRibbonExtensibility

CreateRibbonExtensibilityObject(){return new Ribbon(); }In Ribbon class the

xml file is referred which disable the particular groups from ribbon tab.But

this is applied to all the new mail items not only to my custom form. Or at

least other best option we can see is, catch the send button click event of

outlook and with that we need "Alt+S" and "Cntrl+Enter" event also. Is it

possible?
 
K

Ken Slovak - [MVP - Outlook]

#2
When Outlook asks for the ribbon XML in GetCustomUI() it can only ask for

mail.read or mail.compose. There's no provision in that callback for custom

forms and the callback occurs only once on the first item of that type

that's opened. So you need a different approach.

If you handle Inspectors.NewInspector() you can instantiate an instance of

an Inspector object for only the types of items you want to handle, for

example mail items. You can use reflection to get the Class of the weak

object reference for Inspector.CurrentItem and test it for being olMail.

Then set up that Inspector object or Inspector wrapper class to handle the

Inspector.Activate() event. In that event call ribbon.Invalidate().

If instead of hard disabling the built-in ribbon commands using

enable="false" you can set the XML to call back to your getVisible and

getEnabled callbacks. Calling Invalidate() will fire those callbacks, Since

control.Context will be your Inspector in those callbacks you can cast that

to an Inspector, check for Inspector.CurrentItem.MessageClass and return

values in the getVisible and getEnabled callbacks based on what MessageClass

is returned. Your custom UI can be enabled/disabled using the same logic.

"jubergolandaj" <jubergolandaj> wrote in message

news:34C9F0B8-0A98-4BBA-9BB9-0020B75FA8D9@microsoft.com...
> I am working on Outlook 2007 Add-in developed in C# and VS-2008. In this we
> are having our own custom form .oftOn this form we have our custom "Send"
> button on click event of it our processing continues. Now the problem we
> are
> facing is we want to disable or hide the built-in send button of Outlook
> on
> the Ribbon. Also we want to disable or hide some groups in the Tabs on
> Ribbon. We have tried to do this by using custom Ribbon class implementing
> Office.Core.IRibbonExtensibility interface.In ThisAddin file we have
> written
> the following method: protected override
> Microsoft.Office.Core.IRibbonExtensibility
> CreateRibbonExtensibilityObject(){return new Ribbon(); }In Ribbon class
> the
> xml file is referred which disable the particular groups from ribbon
> tab.But
> this is applied to all the new mail items not only to my custom form. Or
> at
> least other best option we can see is, catch the send button click event
> of
> outlook and with that we need "Alt+S" and "Cntrl+Enter" event also. Is it
> possible?
 
Top