This article shows you how to create VSTO Add-in for Outlook.
There is an MSDN article out there but as usual most of the MSDN articles ask you to visualize the IDE development interface by yourself.
1. Choose File -> click on “Project… (menu item)”.
2. Select Office/SharePoint -> VSTO Add-ins -> Outlook 2013 and 2016 VSTO Add-in.
3. Name your project FirstOutlookAddins.
4. In the ThisAddIn code file, declare a field named
inspectors in the
ThisAddIn class. The
inspectors field maintains a reference to the collection of Inspector windows in the current Outlook instance. This reference prevents the garbage collector from freeing the memory that contains the event handler for the E:Microsoft.Office.Interop.Outlook.InspectorsEvents_Event.NewInspector event.
public partial class ThisAddIn
5. Replace the
ThisAddIn_Startup method with the following code. This code attaches an event handler to the E:Microsoft.Office.Interop.Outlook.InspectorsEvents_Event.NewInspector event.
private void ThisAddIn_Startup(object sender, System.EventArgs e)
inspectors = this.Application.Inspectors;
6. In the ThisAddIn code file, add the following code to the ThisAddIn class. This code defines an event handler for the Microsoft.Office.Interop.Outlook.InspectorsEvents_Event.NewInspector event.
When the user creates a new mail message, this event handler adds text to the subject line and body of the message.
void Inspectors_NewInspector(Microsoft.Office.Interop.Outlook.Inspector Inspector)
Outlook.MailItem mailItem = Inspector.CurrentItem as Outlook.MailItem;
if (mailItem != null)
if (mailItem.EntryID == null)
mailItem.Subject = “This text was added by using code”;
mailItem.Body = “This text was added by using code”;
Press F5 or click the Run button to test your project.