How to create a button like New Mail in Outlook add-in?

4.5k views Asked by At

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

2

There are 2 answers

0
Georg Fritzsche On

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().

0
76mel On

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.