Modifying the email message window

B

Brent

Hi everyone,

I'm trying to add a command bar to the email message window that opens
when you click on "New". I'm trying to do this in C# and am somewhat new
to the Outlook object model. Upon looking at the msdn documentation I
tried using the NewInspector event as follows:



private Outlook.Inspectors myInspectors;

public void Initialize_handler()
{
myInspectors = this.Application.Inspectors;
}

private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
Initialize_handler();
}

private void MyInspectors_NewInspector(Outlook.Inspector Inspector)
{
myBar = Inspector.Commandbars.Add(commandBarName,
Office.MsoBarPosition.msoBarTop, false, true);
}



I've probably not interpreted the VBA documentation correctly. The
object model reference has the following:



Dim myOlApp As New Outlook.Application
Public WithEvents myOlInspectors As Outlook.Inspectors

Public Sub Initialize_handler()
Set myOlInspectors = myOlApp.Inspectors
End Sub

Private Sub myOlInspectors_NewInspector(ByVal Inspector As
outlook.Inspector)
Inspector.CommandBars.Item("Standard").Visible = True
Inspector.CommandBars.Item("Formatting").Visible = True
End Sub


Was I following the right approach? Thanks for any advice!


Brent
 
B

Brent

I've tracked down the problem. There seems to be an issue when Outlook
2003 is using Word 2003 as the email editor. I had a .rtf file open and
all the command bars were getting added there.

I'd like to sort that out eventually but for now it can be alleviated by
unselecting Word 2003 as the email editor under "Options".

My code below is also incorrect and needs:

myInspectors.NewInspector += new
Outlook.InspectorsEvents_NewInspectorEventHandler
(MyInspectors_NewInspector);


Brent
 
K

Ken Slovak - [MVP - Outlook]

To get your UI only showing in WordMail and not Word documents you have to
handle Word code events in your Inspector handler. In the
Word_WindowActivate event you can check for Window.EnvelopeVisible and if
it's true that's a WordMail window. If false it's a Word doc. You can set
your UI visible and enabled properties accordingly.

You should not use NewInspector to set up your UI, that will fail in many
cases. In the Inspector events use the first Inspector.Activate event to
trigger creating your UI.

WordMail also does not honor the Temporary argument and your UI will be
permanent unless you take steps to delete it when the WordMail window is
closing.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top