Examples of how to build C# add-in / plug-in for Outlook, Excel, PowerPoint, FrontPage
Visual C# .NET HOWTOs
- How to program your first C# Outlook add-in
- How to create your first add-in for Microsoft Office in C#
- How to place a .NET control onto a custom Outlook toolbar
- How to put a .NET control onto a custom Excel toolbar in C#
- How to move a custom .NET form embedded into Outlook Explorer or Inspector from one form region to another
- How to cache forms embedded into Outlook Explorer windows
- How to re-size a form embedded into Outlook Explorer or Inspector window
- How to identify the form in an Outlook Advanced Form region in C#
- How to set the visibility of the form in an Outlook Advanced Form Region
- How to use events of Reading Pane, Navigation Pane, and To-Do bar
- How to use several forms in one Advanced Form Region
- How to handle the ItemSend event of MS Outlook in C#
- How to scan Outlook folders
- How to handle Outlook's SelectionChange event
- How to access MAPIFolder from the code of the Outlook property page
- How to handle the ExplorerClose event (Outlook) in C#
- How to add custom menu items to the popup menu in Outlook Explorer
- How to create a command bar and command bar controls at run time (for Outlook)
- How to handle the FrontPage OnWindowActivate event
- How to handle the TaskChange event of MS Project in C#
- How to handle the WorkbookBeforeSave event of MS Excel
- How to handle the MouseClick event on presentation's objects (PowerPoint) in C#
- How to change the CommandBarComboBox (TadxCommandBarComboBox) properties at run time
- How to use dbs as a data source for RTD Servers in C#
- How to create and delete hidden Outlook items via Extended MAPI
1. How to program your first C# Outlook add-in
This Outlook add-in gives an example of how to use Add-in Express 2007 for .NET for:
- Writing one add-in that works across all Outlook versions from Outlook 2000 to Outlook 2007
- Building Outlook-specific command bars and command bar controls
- Creating Outlook 2007 Ribbon controls in Ribbon tabs and Outlook menu
- Creating and controlling Outlook 2007 task panes
- Adding custom property pages to the Tools | Options and Folder Properties dialogs
- Handling application-level events
- Using an event class for handling events of the Items collection (covers adding, removing, or changing Outlook Items)
- Handling keyboard shortcuts
- Using version-neutral Office interop assemblies
- Enabling ready-to-use custom actions in setup projects
You can find this C# Outlook addin in the Samples folder of the Add-in Express installation folder(C:\Program Files\Add-in Express\Add-in Express 2007 for .NET %Edition%\Docs\Samples\). Also, please see the complete list of Add-in Express features for Outlook 2000 - 2007 and Add-in Express flash videos on how to write Outlook 2007 plug-in.
Available downloads:
Sample add-in project for VS 2005 Sample add-in project for VSTO 2005 SE (Outlook 2003)
2. How to create your first add-in for Microsoft Office in C#
This Visual C# sample add-in demonstrates how with Add-in Express 2007 for .NET you can:
- Create an add-in supporting all versions of several Office applications (Excel and Word)
- Build command bars and command bar controls
- Develop 2007 Ribbon controls in Ribbon tabs and Office menu
- Create Office 2007 task panes
- Handle application-level events
- Use event classes for handling worksheet events
- Use version-neutral Office interop assemblies
- Use setup projects generated automatically
- Enable ready-to-use custom actions in the setup project
If you have Add-in Express installed, you can find this C# example in the Samples folder of the Add-in Express installation folder (C:\Program Files\Add-in Express\Add-in Express 2007 for .NET %Edition%\Docs\Samples\). Also, please see a similar sample of building an Office add-in in the online Add-in Express Developer's Guide and flash video showing how to write an Office add-in.
Available downloads:
Sample add-in project for VS 2005 Sample add-in project for VSTO 2005 SE (Excel 2003)
3. How to place a .NET control onto a custom Outlook toolbar
This sample add-in (C# for Visual Studio 2005) intercepts the SelectionChange event of Outlook Explorer and displays selected properties of the currently selected MailItem in a UserControl that is added to a new toolbar. Find more about how to customize Outlook toolbar with any .NET controls. See also a video about customizing Outlook 2003 toolbar.
4. How to put a .NET control onto a custom Excel toolbar in C#
This Excel addin is an example of how to process a number of Excel events: WorkbookActivate, SheetChange, NewWrokbook, etc. In the user-interface, the add-in shows the current state of AutoFilter and allows changing them via the Dialog class of the Excel object model. The sample is written in C# for Visual Studio 2005. See also Add-in Express video about how to add custom .NET controls to Excel toolbar.
5. How to move a custom .NET form embedded into Outlook Explorer or Inspector from one form region to another
When embedding a custom form into an Outlook window, you may want to change the form's layout at run-time. This sample add-in demonstrates how you accomplish this task in C#. The user-interface of the add-in shows a command bar or a Ribbon tab (Office 2007 only) and allows choosing the layout from a combo box. Both source code and the setup project are included. Please note, you may need to change the references for the project to compile.
Available downloads:
Sample add-in project for VS 2005 Sample add-in project for VSTO 2005 Sample add-in project for VSTO 2005 SE
6. How to cache forms embedded into Outlook Explorer windows
For forms embedded into Outlook Explorer windows, Add-in Express provides three form-caching strategies: no caching, showing the same form instance for all folders, and showing a new form instance for each folder. This C# Outlook sample addin demonstrates all the strategies. Please note that forms embedded into Outlook Inspector windows are always non-cached. More about customizing Outlook Explorer views.
Available downloads:
Sample add-in project for VS 2005 Sample add-in project for VSTO 2005. Sample add-in project for VSTO 2005 SE.
7. How to re-size a form embedded into Outlook Explorer or Inspector window
When a form is embedded into an Outlook window, Add-in Express displays a splitter that allows the user to change the size of the form. That's the behavior by default. For the developer to control the size of the form, the splitter should be made invisible (Splitter = None). This C# add-in for Visual Studio 2005 and VSTO is an example that demonstrates this behavior in Outlook 2000 - 2007.
Available downloads:
Sample add-in project for VS 2005 Sample add-in project for VSTO 2005. Sample add-in project for VSTO 2005 SE.
8. How to identify the form in an Outlook Advanced Form region in C#
This C# sample add-in for Visual Studio 2005 and VSTO shows how to identify an instance of the form embedded into an Outlook window. It shows several forms marked with a GUID. When you click on a command bar button (a Ribbon button in an Outlook 2007 inspector), the add-in identifies the currently active form instance and shows its GUID.
Available downloads:
Sample add-in project for VS 2005 Sample add-in project for VSTO 2005. Sample add-in project for VSTO 2005 SE.
9. How to set the visibility of the form in an Outlook Advanced Form Region
This C# sample shows how to hide and show the form embedded into Outlook Explorer and Inspector windows.
Available downloads:
Sample add-in project for VS 2005. Sample add-in project for VSTO 2005. Sample add-in project for VSTO 2005 SE.
10. How to use events of Reading Pane, Navigation Pane, and To-Do bar
This C# sample add-in for Visual Studio 2005 and VSTO 2005 demonstrates how you can make use of the events that are missing in Outlook:
- Show / hide Navigation Pane (FolderList, Outlook Bar)
- Show / hide / move Reading Pane (Preview Pane)
- Show / hide / minimize To-Do Bar
Find more about special features to enhance Outlook bar, To-Do bar, Reading and Navigation panes.
Available downloads:
Sample add-in project for VS 2005. Sample add-in project for VSTO 2005. Sample add-in project for VSTO 2005 SE.
11. How to use several forms in one Advanced Form Region
This sample add-in for VS 2005 and VSTO demonstrates how to use several forms in the same Advanced Form Region. Click a RadioButton on the Controlling form to activate the corresponding ADXOlForm. Find more about the Add-in Express Advanced Outlook Form Region technology.
Available downloads:
Sample add-in project for VS 2005. Sample add-in project for VSTO 2005. Sample add-in project for VSTO 2005 SE.
12. How to handle the ItemSend event of MS Outlook in C#
13. How to scan Outlook folders
14. How to handle Outlook's SelectionChange event
15. How to access MAPIFolder from the code of the Outlook property page
16. How to handle the ExplorerClose event (Outlook) in C#
17. How to add custom menu items to the popup menu in Outlook Explorer
18. How to create a command bar and command bar controls at run time (for Outlook)
19. How to handle the FrontPage OnWindowActivate event
20. How to handle the TaskChange event of MS Project in C#
21. How to handle the WorkbookBeforeSave event of MS Excel
22. How to handle the MouseClick event on presentation's objects (PowerPoint) in C#
23. How to change the CommandBarComboBox (TadxCommandBarComboBox) properties at run time
24. How to use dbs as a data source for RTD Servers in C#
25. How to create and delete hidden Outlook items via Extended MAPI
This sample VS 2005 solution in C# shows how to get, create and delete a hidden item in Outlook and Exchange with MAPI Store Accessor. For more details see the following article: How to get access to hidden Outlook items via Extended MAPI.

