0
votes

Currently, i create a custom VSTO outlook add-on and make it works on our generated emails. However, this custom ribbon always show even if user open other mails. So my question is: is that possible to show/hide ribbon tab if and only if the open mail meets some condition; such as the subject contains a specify word.

Thx in advance.

1

1 Answers

0
votes

Yes, it is possible. Define ribbon callbacks, especially you will be interested in the getVisible one, and use the IRibbonUI.Invalidate or IRibbonUI.InvalidateControl when you need to hide or show your ribbon controls. The getVisible callback has the following signature:

    
C#: bool GetVisible(IRibbonControl control)

VBA: Sub GetVisible(control As IRibbonControl, ByRef visible)

C++: HRESULT GetVisible([in] IRibbonControl *pControl, [out, retval] VARIANT_BOOL *pvarfVisible)

Visual Basic: Function GetVisible(control As IRibbonControl) As Boolean

For example, if an add-in writer implements the getImage callback procedure for a button, the function is called once, the image loads, and then if the image needs to be updated, the cached image is used instead of recalling the procedure. This process remains in place for the control until the add-in signals that the cached values are invalid by using the InvalidateControl method, at which time, the callback procedure is again called and the return response is cached.

Read more about the Fluent UI (aka Ribbon UI) in the following series of articles: