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 (michaelprewecki+todo@gmail.com)
  • Link (michaelprewecki+link@gmail.com)
  • Dev (michaelprewecki+dev@gmail.com)
  • Movie (michaelprewecki+movie@gmail.com)

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

<entry>
 <category term='filter'></category>
 <title>Mail Filter</title>
 <id>tag:mail.google.com,2008:filter:1483750643681</id>
 <updated>2017-01-07T01:31:35Z</updated>
 <content></content>
 <apps:property name='to' value='michaelprewecki+todo@gmail.com'/>
 <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'/>
 </entry>

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("michaelprewecki@gmail.com", "Michael Pewecki");
 var toAddress = new MailAddress(String.Format("michaelprewecki+{0}@gmail.com", category), "Michael Prewecki");
 const string fromPassword = "<apppassword>"; // This needs to be generated within https://myaccount.google.com/security if you use two factor authentication (and you should be).

 var smtp = new SmtpClient
 {
  Host = "smtp.gmail.com",
  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
 })
 {
  smtp.Send(message);
 }
}

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 *