Home ProgrammingC# Visual C# : Create Outlook VSTO plugin

Visual C# : Create Outlook VSTO plugin

by Kliment Andreev
0 comment
Reading Time: 2 minutes

I used Visual C# and MS Office Development Tools to create a VSTO plugin for Outlook. Anytime you receive an email that have the words “please advise”, “please assist” or “kindly”, you’ll see a red banner in the email.

As Urban Dictionary says, please advise is “an extremely stuffy phrase used by business executives to close emails when they don’t understand how to ask a real question. It basically means Please use your imagination to figure out what the f* I need to know to make a decision on this item without making me look like an idiot in front of all the people I CCed”

Dear Luke,

I recently got a call from Alex in LA telling me that we're out of blinkity blank in California so the blippity blue isn't working. 
What-the-f* we're losing 15k a day what-the-f* save me please.

Please Advise, 

So…. Go to Visual Studio, choose a new Project and select Outlook. I did mine for Outlook 2010, but it should be very similar for 2013 and 2016.


Once you have the template, update the methods, so it looks like the source below. Change the list of words if you like (line 29), then compile and run and the add-in will be automatically added to Outlook. If you want to distribute it, it’s a bit more complicated, but check this page or this page.

If everything is OK, next time you receive an e-mail it will look like this.


using System.Collections.Generic;
using System.Linq;
using Outlook = Microsoft.Office.Interop.Outlook;

namespace PleaseAdvise
    public partial class ThisAddIn

        Outlook.NameSpace outlookNameSpace;
        Outlook.MAPIFolder inbox;
        Outlook.Items items;

        private void ThisAddIn_Startup(object sender, System.EventArgs e)
            outlookNameSpace = this.Application.GetNamespace("MAPI");
            inbox = outlookNameSpace.GetDefaultFolder(

            items = inbox.Items;
            items.ItemAdd +=
                new Outlook.ItemsEvents_ItemAddEventHandler(items_ItemAdd);

        void items_ItemAdd(object Item)
            List<string> lstKeyWords = new List<string>(new string[] { "PLEASE ADVISE", "PLEASE ASSIST", "KINDLY" });
            Outlook.MailItem mail = (Outlook.MailItem)Item;
            if (Item != null)
                bool bSubject = lstKeyWords.Any(mail.Subject.ToUpper().Contains);
                bool bBody = lstKeyWords.Any(mail.Body.ToUpper().Contains);
                if ((mail.MessageClass == "IPM.Note") && (bSubject || bBody))
                    mail.FlagIcon = Outlook.OlFlagIcon.olRedFlagIcon;
        private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
            // Note: Outlook no longer raises this event. If you have code that 
            //    must run when Outlook shuts down, see http://go.microsoft.com/fwlink/?LinkId=506785

        #region VSTO generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InternalStartup()
            this.Startup += new System.EventHandler(ThisAddIn_Startup);
            this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
0 comment

Related Articles

Leave a Comment

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More