Addin for outlook 2007 using Visual studio 2008

N

Neetu

I have to create a add-in for outlook using Visual studio 2008 for outlook
2007.
Need to create a commandbarbutton on each inspector if item type is mail.
on NewInspector event , i wrote this code.

void Inspectors_NewInspector(Microsoft.Office.Interop.Outlook.Inspector
Inspector)
{

if (Inspector != null)
{
if (Inspector.CurrentItem is
Microsoft.Office.Interop.Outlook.MailItem)
{


Office.CommandBarButton objCommandbar;
try
{
objCommandbar =
(Office.CommandBarButton)Inspector.CommandBars["Standard"].Controls[_strMycommandbuttonName];
}
catch (Exception ex)
{

objCommandbar =
(Office.CommandBarButton)Inspector.CommandBars["Standard"].Controls.Add(1,
System.Reflection.Missing.Value, System.Reflection.Missing.Value,
System.Reflection.Missing.Value, true);
objCommandbar.Style =
Microsoft.Office.Core.MsoButtonStyle.msoButtonCaption;
objCommandbar.Caption = _strMycommandbuttonName;
objCommandbar.Tag = _strMycommandbuttonName;
objCommandbar.Visible = true;
objCommandbar.Click += new
Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(objCommandbar_Click);
}
}
}

}

a new button has been created in my outlook however it is coming inside
another tab called "Addin" after "Message" tab.

However I want this new button in same "Message" tab.
how can achieve that?

Also I want to give a good picture to Button.
How can i add image to my custom button.

Thanks
Neetu
 
K

Ken Slovak - [MVP - Outlook]

Outlook 2007 uses the Ribbon and any command bar controls you add will go
into that Addins tab along with any other buttons created by other code. Use
the Ribbon to add your UI. Go to the Office Developer Web site at MS and
review the tons of material there on using the Ribbon.

A word of advice, this won't affect the ribbon, which uses callbacks for its
events and uses XML to supply the Ribbon UI, but it's not a good idea to try
to do very much with an item or Inspector in NewInspector(). The object
references you get in that event are "weak" and don't provide all the
properties that are available later, for example in the first
Inspector.Activate() event. NewInspector should only be used to instantiate
an Inspector object and to test for Inspector.CurrentItem.Class or
..MessageClass. As an example, try getting Inspector.IsWordMail in
NewInspector(), it will be false even though in Outlook 2007 it always is
true after the first Activate() event.
 
N

Neetu

Thanks Ken, for reply.
Is it possible to use Ribbin to Outlook 2003. or office word 2003 and office
word 2007?





Ken Slovak - said:
Outlook 2007 uses the Ribbon and any command bar controls you add will go
into that Addins tab along with any other buttons created by other code. Use
the Ribbon to add your UI. Go to the Office Developer Web site at MS and
review the tons of material there on using the Ribbon.

A word of advice, this won't affect the ribbon, which uses callbacks for its
events and uses XML to supply the Ribbon UI, but it's not a good idea to try
to do very much with an item or Inspector in NewInspector(). The object
references you get in that event are "weak" and don't provide all the
properties that are available later, for example in the first
Inspector.Activate() event. NewInspector should only be used to instantiate
an Inspector object and to test for Inspector.CurrentItem.Class or
..MessageClass. As an example, try getting Inspector.IsWordMail in
NewInspector(), it will be false even though in Outlook 2007 it always is
true after the first Activate() event.




Neetu said:
I have to create a add-in for outlook using Visual studio 2008 for outlook
2007.
Need to create a commandbarbutton on each inspector if item type is mail.
on NewInspector event , i wrote this code.

void Inspectors_NewInspector(Microsoft.Office.Interop.Outlook.Inspector
Inspector)
{

if (Inspector != null)
{
if (Inspector.CurrentItem is
Microsoft.Office.Interop.Outlook.MailItem)
{


Office.CommandBarButton objCommandbar;
try
{
objCommandbar =
(Office.CommandBarButton)Inspector.CommandBars["Standard"].Controls[_strMycommandbuttonName];
}
catch (Exception ex)
{

objCommandbar =
(Office.CommandBarButton)Inspector.CommandBars["Standard"].Controls.Add(1,
System.Reflection.Missing.Value, System.Reflection.Missing.Value,
System.Reflection.Missing.Value, true);
objCommandbar.Style =
Microsoft.Office.Core.MsoButtonStyle.msoButtonCaption;
objCommandbar.Caption = _strMycommandbuttonName;
objCommandbar.Tag = _strMycommandbuttonName;
objCommandbar.Visible = true;
objCommandbar.Click += new
Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(objCommandbar_Click);
}
}
}

}

a new button has been created in my outlook however it is coming inside
another tab called "Addin" after "Message" tab.

However I want this new button in same "Message" tab.
how can achieve that?

Also I want to give a good picture to Button.
How can i add image to my custom button.

Thanks
Neetu
 
K

Ken Slovak - [MVP - Outlook]

The ribbon was added in Office 2007 and does not exist in Office 2003 or
earlier.




Neetu said:
Thanks Ken, for reply.
Is it possible to use Ribbin to Outlook 2003. or office word 2003 and
office
word 2007?





Ken Slovak - said:
Outlook 2007 uses the Ribbon and any command bar controls you add will go
into that Addins tab along with any other buttons created by other code.
Use
the Ribbon to add your UI. Go to the Office Developer Web site at MS and
review the tons of material there on using the Ribbon.

A word of advice, this won't affect the ribbon, which uses callbacks for
its
events and uses XML to supply the Ribbon UI, but it's not a good idea to
try
to do very much with an item or Inspector in NewInspector(). The object
references you get in that event are "weak" and don't provide all the
properties that are available later, for example in the first
Inspector.Activate() event. NewInspector should only be used to
instantiate
an Inspector object and to test for Inspector.CurrentItem.Class or
..MessageClass. As an example, try getting Inspector.IsWordMail in
NewInspector(), it will be false even though in Outlook 2007 it always is
true after the first Activate() event.




Neetu said:
I have to create a add-in for outlook using Visual studio 2008 for
outlook
2007.
Need to create a commandbarbutton on each inspector if item type is
mail.
on NewInspector event , i wrote this code.

void Inspectors_NewInspector(Microsoft.Office.Interop.Outlook.Inspector
Inspector)
{

if (Inspector != null)
{
if (Inspector.CurrentItem is
Microsoft.Office.Interop.Outlook.MailItem)
{


Office.CommandBarButton objCommandbar;
try
{
objCommandbar =
(Office.CommandBarButton)Inspector.CommandBars["Standard"].Controls[_strMycommandbuttonName];
}
catch (Exception ex)
{

objCommandbar =
(Office.CommandBarButton)Inspector.CommandBars["Standard"].Controls.Add(1,
System.Reflection.Missing.Value, System.Reflection.Missing.Value,
System.Reflection.Missing.Value, true);
objCommandbar.Style =
Microsoft.Office.Core.MsoButtonStyle.msoButtonCaption;
objCommandbar.Caption = _strMycommandbuttonName;
objCommandbar.Tag = _strMycommandbuttonName;
objCommandbar.Visible = true;
objCommandbar.Click += new
Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(objCommandbar_Click);
}
}
}

}

a new button has been created in my outlook however it is coming inside
another tab called "Addin" after "Message" tab.

However I want this new button in same "Message" tab.
how can achieve that?

Also I want to give a good picture to Button.
How can i add image to my custom button.

Thanks
Neetu
 

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