J
Jessica Holtz
Hi all!
I'm hoping that someone can help me with a problem I'm having!
I'm trying to attach to the reply button in Outlook 2003 with C#, but I'm
getting an exception thrown everytime I try to access a commandbar, such as
"Standard"!
My code looks like:
private static Outlook.Application oApplication;
private static Microsoft.Office.Core.CommandBarButton cbExplReply;
.....
public void OnConnection(object application, Extensibility.ext_ConnectMode
connectMode, object addInInst, ref System.Array custom)
{
try
{
oApplication = (Outlook.Application)application;
Microsoft.Office.Core.CommandBar cbStandard =
(Microsoft.Office.Core.CommandBar)oApplication.ActiveExplorer().CommandBars[
"Standard"]; //Exception thrown on this line
cbExplReply =
(Microsoft.Office.Core.CommandBarButton)cbStandard.Controls["Reply"];
cbExplReply.Click += new
Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(OnToolbarBut
tonClick);
}catch( Exception ex )
{
System.Windows.Forms.MessageBox.Show( ex.ToString() );
}
}
private static void OnToolbarButtonClick(CommandBarButton cmdBarbutton,ref
bool cancel)
{
System.Windows.Forms.MessageBox.Show("Hello World","Jessica Addin");
}
This throws a:
System.NullReferenceException: Object reference not set to an instance of an
object.
at MyAddinJessica.Connect.OnConnection(Object application,
ext_ConnectMode connectMode, Object addInInst, Array& custom) in
c:\implementation\source_code\interface\connect.cs:line 178
Thanks Much!
Jessica
I'm hoping that someone can help me with a problem I'm having!
I'm trying to attach to the reply button in Outlook 2003 with C#, but I'm
getting an exception thrown everytime I try to access a commandbar, such as
"Standard"!
My code looks like:
private static Outlook.Application oApplication;
private static Microsoft.Office.Core.CommandBarButton cbExplReply;
.....
public void OnConnection(object application, Extensibility.ext_ConnectMode
connectMode, object addInInst, ref System.Array custom)
{
try
{
oApplication = (Outlook.Application)application;
Microsoft.Office.Core.CommandBar cbStandard =
(Microsoft.Office.Core.CommandBar)oApplication.ActiveExplorer().CommandBars[
"Standard"]; //Exception thrown on this line
cbExplReply =
(Microsoft.Office.Core.CommandBarButton)cbStandard.Controls["Reply"];
cbExplReply.Click += new
Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(OnToolbarBut
tonClick);
}catch( Exception ex )
{
System.Windows.Forms.MessageBox.Show( ex.ToString() );
}
}
private static void OnToolbarButtonClick(CommandBarButton cmdBarbutton,ref
bool cancel)
{
System.Windows.Forms.MessageBox.Show("Hello World","Jessica Addin");
}
This throws a:
System.NullReferenceException: Object reference not set to an instance of an
object.
at MyAddinJessica.Connect.OnConnection(Object application,
ext_ConnectMode connectMode, Object addInInst, Array& custom) in
c:\implementation\source_code\interface\connect.cs:line 178
Thanks Much!
Jessica