Autosorting Email

I use gmail…alot, I regularly send myself emails that fall into a number of distinct categories. Then every so often I go through a big cull of my inbox and transfer those important items into my todo list.

I’ve used labels in gmail for years and have had a great deal of success keeping my emails organised. The manual dragging of items into those labels has just been getting me down so I figured there had to be a better way.

I’ve recently be using aliases in gmail and stuck upon an idea that is working perfectly. In a nut shell I have now set up a bunch of aliases, a bunch of keyword contacts for those aliases and filters and labels for each alias. In addition I have a small utility that simply uses gmail to send emails to myself from my desktop using command line arguments and slick run (this won’t work from the office because the connection is port 587 but a simple replacement with mailto: will do the job.

For example I have the following 4 keywords

  • Todo :- Something I need to do.
  • Link :- Something I want to read (an article or short story).
  • Dev :- A development thing I want to read, watch or do.
  • Movie :- A movie I want to watch.

Part 1 : Getting organised

I have created 4 contacts in my address book with the following email addresses

  • Todo (
  • Link (
  • Dev (
  • Movie (

Then I have 4 filters on these within gmail that look like this

 <category term='filter'></category>
 <title>Mail Filter</title>
 <apps:property name='to' value=''/>
 <apps:property name='label' value='P/My Todo'/>
 <apps:property name='shouldArchive' value='true'/>
 <apps:property name='sizeOperator' value='s_sl'/>
 <apps:property name='sizeUnit' value='s_smb'/>

Note the only bits that change for me are the alias and the label. In gmail you can go to Settings | Filters and Blocked Addresses and import and export filters, so these can be setup really quickly.

Now whenever I need to do something later it’s simply a case of sending an email to my contact “Todo” with the subject or body containing the thing todo. At which point it will all be nicely organised under an gmail “label” (think folder) within gmail. This is especially handy for other things like links that I want to read later because the share facility on most sites allows me to email the link so all I need to do is type the contact and my links gets nicely organised (think less time filing email and more time processing them).

Part 2 : Slick Run & My Mailer Utility

The second part uses an application launcher called slick run. A fantastic little utility that lets you launch applications using keystrokes. Using the following code in a little windows application i’m able to send emails using slick run MagicWords.

if (args.Length == 2)
 var category = args[0];
 var subject = args[1].Replace("+", " ");

 var fromAddress = new MailAddress("", "Michael Pewecki");
 var toAddress = new MailAddress(String.Format("michaelprewecki+{0}", category), "Michael Prewecki");
 const string fromPassword = "<apppassword>"; // This needs to be generated within if you use two factor authentication (and you should be).

 var smtp = new SmtpClient
  Host = "",
  Port = 587,
  EnableSsl = true,
  DeliveryMethod = SmtpDeliveryMethod.Network,
  UseDefaultCredentials = false,
  Credentials = new NetworkCredential(fromAddress.Address, fromPassword)
 using (var message = new MailMessage(fromAddress, toAddress)
  Subject = subject,
  Body = String.Empty

With this code in place in a compiled application (create the project as a console application and then change the output to a windows application so that you in effect have a windowless windows application). You can setup a MagicWord in slick run similar to the following

Then when you want to do something later you simply

  • Press Alt + Q (activate slick run keyword entry)
  • Type “todo” and press enter
  • Type the thing that needs to be done and press enter (this will fill in the $W$ command line argument).
  • voila, your email will be sent and be auto-filed for you.


Leave a Reply

Your email address will not be published. Required fields are marked *