I am new to Outlook programming, so for the first step (later) this is the following task:
- Create a new ribbon tab (Ribbon1) (should be shown to researchers and new inspectors)
- When you select (Explore) or open (Inspector) mail on the ribbon tab, the subject of the letter should be displayed (as indicated in the test).
Explorer was pretty simple, but I have problems with this for new inspectors
I tried different approaches, but no one works:
I tried in NewInspector to reference Globals.Ribbons [inspector] .Ribbon1, but it's always null
I tried in NewInspector to subscribe to the Activate event and do it from there, but there 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 subsequent reading of the mail, not for composing mail)
I tried to use the Ribbon Load event, but this only happens for the first time
I tried to use a member of Globals.Ribbons.Ribbon1, but only for the first time
(I found many NewInspector samples, but no one seems to want to change the feed other than this https://stackoverflow.com/questions/7852017/outlook-2007-ribbon-object-reference-not-set-to-an- instance-of-an-object , and there are no answers for this)
It drives me crazy ... Is there no way to do such a simple task!
void InspectorsNewInspector(Outlook.Inspector inspector)
{
AddInspectorEventHandlers(inspector);
}
private void AddInspectorEventHandlers(Outlook.Inspector inspector)
{
if (inspector == null)
{
return;
}
Ribbon1 ribbon1 = Globals.Ribbons[inspector].Ribbon1;
((Outlook.InspectorEvents_10_Event)inspector).Activate += InspectorActivate;
((Outlook.InspectorEvents_10_Event)inspector).Close += InspectorClose;
_openInspectors.Add(inspector);
}