Linking you OneNote notes to your Outlook tasks

Pretty much I am writing this for someone as a proof of concept and I thought I would share it with all of you J. You know how you can create Outlook tasks directly from OneNote and they appear in Outlook? They look like this:

And it appears in my Todo Bar in Outlook and I can check of an item and it appears in OneNote as done. The two-way task sync was one of our most popular feature requests from OneNote 2003 SP1. Now some questions are:

  1. How does this work? Lets look under the hood shall we?
  2. Can I create my own tasks that look like this in OneNote that are linked to my Outlook tasks that weren't created by OneNote.

Let's resolve both of these with this blog post.

How linked Outlook tasks work

First of all we do this feature by adding two special fields to the outlook task item, they are: OneNoteTaskID & OneNoteURL. So for the task that I just created let's see what it looks like in Outlook.

I am going to use the Developer tab on the Ribbon, to see this open an Outlook task and choose File/Office ButtonàEditor Options and turn on to view the developer tab. So when I go into the task I click on Design this Form here:

Then I choose (All Fields) and I can see this:

There are the custom fields that OneNote put on this tasks when it was created. Now what does the XML look like in OneNote? Let's see here:

<one:Outline
author="descapa"
lastModifiedBy="descapa"
lastModifiedTime="2006-09-08T23:41:25.000Z"
objectID="{A16F23FE-EF62-4443-A679-4C614C5A568E}{28}{B0}">

<one:Position
x="36.0"
y="86.4000015258789"
z="0" />

<one:Size
width="228.8948211669922"
height="13.42771339416504" />

<one:OEChildren>

<one:OE
creationTime="2006-09-08T23:41:16.000Z"
lastModifiedTime="2006-09-08T23:41:25.000Z"
objectID="{A16F23FE-EF62-4443-A679-4C614C5A568E}{29}{B0}"
alignment="left">

<one:OutlookTask
startDate="2006-09-08T00:00:00.000Z"
dueDate="2006-09-08T00:00:00.000Z"
guidTask="{AD9B64F6-A770-4509-931B-DDB71A4F8710}"
completed="false"
disabled="false"
creationDate="2006-09-08T23:41:25.000Z" />

<one:T><![CDATA[Blog about how to create links to tasks]]></one:T>

</one:OE>

</one:OEChildren>

</one:Outline>

 

Look @ the highlighted text, and you can see that the guidTask is the same that appeared in Outlook. So that is how everything works.

Creating your own links

How do I create my own? Let me create a new line of text in OneNote which looks like this:

Now this XML looks like this:

<one:Outline
author="descapa"
lastModifiedBy="descapa"
lastModifiedTime="2006-09-08T23:50:33.000Z"
objectID="{25B09B42-B8F0-4906-91AB-A38C7F003991}{28}{B0}">

<one:Position
x="36.0"
y="86.4000015258789"
z="0" />

<one:Size
width="120.360939025879"
height="13.42771339416504" />

<one:OEChildren>

<one:OE
creationTime="2006-09-08T23:50:28.000Z"
lastModifiedTime="2006-09-08T23:50:33.000Z"
objectID="{25B09B42-B8F0-4906-91AB-A38C7F003991}{29}{B0}"
alignment="left">

<one:T><![CDATA[Blog test tasks]]></one:T>

</one:OE>

</one:OEChildren>

</one:Outline>

Now I just need to add one line for the one:OutlookTask, see here for what I send to OneNote via UpdatePageContent, see here:

<one:OutlookTask
startDate="2006-09-08T00:00:00.000Z"
dueDate="2006-09-08T00:00:00.000Z"
guidTask="{AD9B64F6-A770-4509-931B-DDB71A4F871A}"
completed="false"
disabled="false" />

Note:

  1. You should check your Outlook task with the correct startDate and dueDate information and other items
  2. The GUIDs need to be unique, you can create them programmatically but I just went from 0-->A (hex counting)

So what I send back into OneNote via the API is:

<one:Outline
author="descapa"
lastModifiedBy="descapa"
lastModifiedTime="2006-09-08T23:50:33.000Z"
objectID="{25B09B42-B8F0-4906-91AB-A38C7F003991}{28}{B0}">

<one:Position
x="36.0"
y="86.4000015258789"
z="0" />

<one:Size
width="120.360939025879"
height="13.42771339416504" />

<one:OEChildren>

<one:OE
creationTime="2006-09-08T23:50:28.000Z"
lastModifiedTime="2006-09-08T23:50:33.000Z"
objectID="{25B09B42-B8F0-4906-91AB-A38C7F003991}{29}{B0}"
alignment="left">

<one:OutlookTask
startDate="2006-09-08T00:00:00.000Z"
dueDate="2006-09-08T00:00:00.000Z"
guidTask="{AD9B64F6-A770-4509-931B-DDB71A4F871A}"
completed="false"
disabled="false" />

<one:T><![CDATA[Blog test tasks]]></one:T>

</one:OE>

</one:OEChildren>

</one:Outline>

Note that only one line changed and now in OneNote I see this:

Okay so now we are ready to set the fields on the Outlook item. For this experience let's say that I already had an Outlook task called "Test task in OLK" and now I just open it up and choose to change the form again, but this time instead of choosing "User-defined fields in this item" I choose "User-defined fields in folder" and I see this:

So now I just need to set the OneNoteTaskID to what I inserted earlier: {AD9B64F6-A770-4509-931B-DDB71A4F871A} and I would need to insert the hyperlink back to that item (which can be found with GetHyperlinkToObject). So let me set those properties here:

And save my tasks and then after a quick sync OneNote sees this change here:

I can check off items in OneNote and it goes to Outlook and vice-versa, just like if you had created the task directly in OneNote:

Why did I blog about this?

Imagine that you wanted to do your own GTD application which would look at your Outlook tasks and you wanted to create a summary page in OneNote, much like our tag summary page. Here is how you would do this, all programmatically of course. I just wanted to show you how it could be done. Maybe if I have more time I could code up something like this myself, who knows.