views:

501

answers:

4

Can anyone pls tell me how to create a button(in CommandBar) like 'New Mail' (with a dropdown list) in Outlook? When one clicks on the button it should do some action and when clicked on the down arrow mark, it should populate a list of items. I am in need of this very much. If anyone know the answer pls let me know.

Thanks in advance!

-Pranav

A: 

Assuming Outlook<2007, you add a new button to the explorer/inspector via CommandBars.Add("foo", Type:=msoControlDropdown) and add entries to the drop-down via myDropdown.Add("bar"). See also the reference for CommandBarComboBox.
You can't populate it on click though, you have to find other suitable events for that, e.g. Explorer.SelectionChange.

On Outlook >= 2007 you need to customize the ribbon which is a bit more writing work. Customizing the Ribbon in Outlook 2007 is a good introduction into that.

To create a new mail item use myOlApplication.CreateItem(olMailItem) or myMailFolder.Items.Add(), set it up as needed and show it in an inspector via e.g. myMailItem.Display().

Georg Fritzsche
A: 

hi gf, thanks for the quick reply.

i have already implemented the above which you said. but i want a button with dropdown facility (like 'New' button in outlook which creates a new mail item when clicked on it. And populates a list when clicked on the down arrow mark beside the button).

is it possible to implement this using vsto?

-Pranav

Pranav
As i said, you can't populate it on click via the Outlook Object Model, you have to do this somewhere else.<br/>You haven't mentioned that you need to create new mails items though. Also you're not saying if you need them to be visible in a new inspector etc. ...
Georg Fritzsche
A: 

Sound like you are looking for a split button. Unfortunately the API does not expose that. You can hack up a Popup under the button which is a poor attempt of a split button.

76mel