Freigeben über


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.

Comments

  • Anonymous
    September 08, 2006
    Hey, this is a great write-up.  I've been a big OneNote fan for a couple of years and this is a feature that I've really been looking forward to.  And it's nice to see how it works.
    Thanks for doing this!
    -Don

  • Anonymous
    September 09, 2006
    We hear the next version is around the corner, and it was originally due at the end of the summer , which is now I guess.
    Just can't wait for it!

  • Anonymous
    November 25, 2006
    Having some problems with this.  I'm trying to create the task based on the current 'thing' selected, so I did this: // Get the current text block XmlElement elem = doc.SelectSingleNode("//one:T[@selected="all"]", this.nsmgr) as XmlElement; XmlNode node = elem.ParentNode; Then I prepend the outlook task item: string when = string.Format("{0}.000Z", DateTime.Now.ToString("s")); Guid g = Guid.NewGuid(); string newXml = string.Format("<one:OutlookTask startDate="{0}" dueDate="{0}" guidTask="{{{1}}}" completed="false" disabled="false" />",                when, g.ToString()); newXml += node.InnerXml; Whenever I call oneNoteApplication.UpdatePageContent(node.InnerXml, DateTime.MinValue) though I get a COM error of 0x80042000, which seems to mean malformed XML.  What am I doing wrong?

  • Anonymous
    November 27, 2006
    Scott - What version of OneNote are you using?  The RTM version, B2TR?  Also could you please use the comment link @ the top of the page so we can take this offline via email?  Thanks!

  • Anonymous
    February 09, 2008
    <a href= http://index1.findvic.com >russian girl nude</a>

  • Anonymous
    February 09, 2008
    <a href= http://index1.findvic.com >russian girl nude</a>

  • Anonymous
    June 03, 2008
    How does one expose the xml? I would like to populate a custom field in outlook tasks with the name of the section that the task was spawned from I have no idea where to begin really as I don't usually program but I'll give this a good go.