I'm new to Outlook programming so for the first step (more advanced later) is the following task:
- Create a new ribbon (Ribbon1) tab (should be shown in explorers and new inspectors)
- When selecting (Explore) or opening (Inspector) a mail the ribbon tab should show the subject of the mail (As mentioned to test)
The Explorer part was quite easy to get going but I have problems doing the above for new inspectors
I've tried various approaches but none seem to work:
I've tried in the NewInspector to reference the Globals.Ribbons[inspector].Ribbon1 but that is always null
I've tried in the NewInspector to subscribe to the Activate event and do it from there but in there the Application.ActiveInspector() is null and if I store a global copy of the inspector from the NewInspector event it does not Work on the first new inspector (only after the second and on on read mails. not on compose mail)
I've tried to use Ribbon Load event but that only happens the first time
I've tried to use the Globals.Ribbons.Ribbon1 member but that only Work for the first time
(I've found lots of samples of NewInspector but no one seem to want to modify the ribbon other than this one https://stackguides.com/questions/7852017/outlook-2007-ribbon-object-reference-not-set-to-an-instance-of-an-object and for that there are no answers)
This is driving me crazy... Is there really no way to do such a simple task!?
Sample code for reference
void InspectorsNewInspector(Outlook.Inspector inspector)
{
AddInspectorEventHandlers(inspector);
}
private void AddInspectorEventHandlers(Outlook.Inspector inspector)
{
if (inspector == null)
{
return;
}
Ribbon1 ribbon1 = Globals.Ribbons[inspector].Ribbon1; //This always return null!!!
((Outlook.InspectorEvents_10_Event)inspector).Activate += InspectorActivate;
((Outlook.InspectorEvents_10_Event)inspector).Close += InspectorClose;
_openInspectors.Add(inspector);
}
InspectorsNewInspector
. The entire AddIn class will be beneficial for context. – SliverNinja - MSFT