Outlook and no-reply

Often I get mails from our server with various information, and me and my coworkers are all included, and in number of times I reply to that mail with some comments. Outlook includes that no-reply mail in recipients and every time I have to go to recipients list and manually remove that no-reply mails. It's annoying and I am pretty lazy. So I wrote little outlook addin to exclude such mails.


Visual Studio 2013 Solution - soruce code


1. Unpack installation archive into destination folder (addon will install it self in that folder)
2. Import certificate from destination folder into Thrusted People or Thrusted Publishers certificate authority
3. Execute setup.exe from destination folder
4. Start Outlook and click Reply All on some random mail. (that will createOutlookAddInExcludeFromReplyAll.dll.config)
5. Modify OutlookAddInExcludeFromReplyAll.dll.config to add or remove mails that needs to be removed, you can change settings:
Each of these settings can contains more than one e-mail separated by ; (semi-colon), here is the screenshot of default settings:

 OutlookAddInExcludeFromReplyAll screenshot of default settings


Visual Studio 2010 Solution - soruce code
Office 2010 instalation

Here is the source code :

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

namespace OutlookAddInExcludeFromReplyAll
    public partial class AddInExcludeFromReplyAll
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
          Globals.AddInExcludeFromReplyAll.Application.ItemLoad += new Microsoft.Office.Interop.Outlook.ApplicationEvents_11_ItemLoadEventHandler(Application_ItemLoad);

        private void ThisAddIn_Shutdown(object sender, System.EventArgs e)

        private void Application_ItemLoad(object Item)
          if (Item is Outlook.ItemEvents_10_Event)
            (Item as Outlook.ItemEvents_10_Event).ReplyAll += new Microsoft.Office.Interop.Outlook.ItemEvents_10_ReplyAllEventHandler(ThisAddIn_ReplyAll);

        private void ThisAddIn_ReplyAll(object response, ref bool cancel)
          MailItem mi = (MailItem)response;
          var mailList = Properties.Settings.Default.ExcludeMails.Split(';').ToList();
          var startList = Properties.Settings.Default.ExcludeMailsThatStartWith.Split(';').ToList();
          var endList = Properties.Settings.Default.ExcludeMailsThatEndsWith.Split(';').ToList();
          foreach (Recipient rcp in mi.Recipients.Cast<Recipient>().ToList())
            bool wholeMailHit = mailList.Any(ml => rcp.Address.Equals(ml, StringComparison.InvariantCultureIgnoreCase));
            bool startHit = startList.Any(ml => rcp.Address.StartsWith(ml, StringComparison.InvariantCultureIgnoreCase));
            bool endHit = endList.Any(ml => rcp.Address.EndsWith(ml, StringComparison.InvariantCultureIgnoreCase));

            if (wholeMailHit || startHit || endHit)

        #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);