I have to override the "Forward" button in a mail Item whn User tries to forward Item from a particulare Folder.

the .GetInspector always throws an Error.

Is there somthin wrong in the way this is implemented

Please let me know

This is the code I am using:

Outlook.Explorer m_Explorer = _Explorers.Application.ActiveExplorer();

string strFolderName = m_Explorer.CurrentFolder.Name;

if (Equals(strFolderName, "Dont Allow Forward Folder"))


object objItem;

objItem = Inspector.CurrentItem;

// If a Mail Item has been Opened From the "Secure Messages" Folder

if (objItem is Outlook.MailItem)


Outlook.MailItem mailItem = objItem as Outlook.MailItem;


// Inspector Menu BARs

m_InspectorMenuBar = m_MailItem.GetInspector.CommandBars.ActiveMenuBar;

// Inspector Menu BAR POPUP

m_InspectorCommandBarPopUp = (Office.CommandBarPopup)m_InspectorMenuBar.Controls["Forward"];



Re: Visual Studio Tools for Office To override the "Forward" button in a mail Item

Ji Zhou – MSFT

Hi Madhooo,

First, could you please post your exact exception message here That would be helpful to know what the problem is. Second, when you are saying override the “Forward” button what you want to achieve Third, when I use mailItem.GetInspector, it always gives me the right inspector I want, but not an exception. Is it potential that error is thrown out when get ActiveMenuBar or set m_InspectorMenuBar (And I cannot see your declaration of m_InspectorMenuBar)

If you just want to get the Forward Button. The following codes work fine for me:

Code Snippet

bool found = false;

Outlook.Explorer explorer = app.ActiveExplorer();

Outlook.Inspector inspector = app.ActiveInspector();

if (explorer.CurrentFolder.Name == "Inbox")


foreach (Office.CommandBar cb in inspector.CommandBars)


foreach (Office.CommandBarControl cbc in cb.Controls)


if (cbc.Caption == "For&ward")


found = true;





if (found)







I hope this can help. If you still cannot resolve the issue, please feel free to let me know and follow up with more information. We will have some future discussion about that. J