22 May, 2009

Adding outlook tasks fast (using Launchy with a little programming)

Being home from work with a stomach bug today I was thinking on how I can be more effective in what I do. One thing that popped to mind is how often in a work day I lose track of what I’m doing just because I remember something else I have to do. When the idea pops up I go off to outlook navigate to the right place, add a task… And boom, my mind is way off track.

So my thought was “how do I shorten the interruption so that it does not derail my train of thought”?

I’m a big fan of Launchy. It rocks and saves me time every day. So I figured that was the way to go and since I’m a computer nerd I immediately cracked open Visual Studio and got to work (if a hammer is the only tool you have, every problem looks like a nail :)).

Here is the achieved result:

OutLookTask_In_Launchy

Which puts the task in Outlook:

TaskInOutlook

The code I used for this is very simple. Here is the code for opening up Outlook and creating the task.

Main(string[] args)
{
    Microsoft.Office.Interop.Outlook.Application olApp;
    Microsoft.Office.Interop.Outlook.NameSpace ns = null;
    try
    {
        olApp = new Outlook.Application();
        ns = olApp.GetNamespace("mapi");

        ns.Logon("Outlook", Missing.Value, false, true);

        Outlook.TaskItem ti = olApp.CreateItem(Outlook.OlItemType.olTaskItem) as Outlook.TaskItem;
        ti.Assign();
        ti.Subject = GetTaskSubject(args);
        ti.DueDate = GetDueDate(args[0]);
        ti.Save();
    }
    catch (Exception ex)
    {
        Console.WriteLine(ex.Message);
        throw;
    }
    finally
    {
        ns.Logoff();
    }
}

And in addition to that it’s just some parsing logic. The first word is my own little micro language. td –today, tm – tomorrow, nw – next week, jan – januari and so on. Check the huge switch-case statement in the code to se all my code words.

So this is just in the prototype state so far, but works pretty good. The code needs some heavy refactoring and so on, but if you want to check it out. Download code here.

For the next step I’m looking at making it a “real” Launcy plug-in. Since I don’t want to step into C++ land I leaning towards the Launchy# project.

UPDATE 2009-06-11: By request I’ve uploaded a compiled exe that you can download here.


Tags: ,