|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
IntroductionThis Addin is designed to solve a problem some users of OneNote face. Once people start using OneNote, many of them tend to move all their data into it. They then experience the problem of being away from OneNote and having information they want to add to it. Their only access may be to email, such as with a mobile phone or airport kiosk. They could rely on new functionality in Outlook 2007 which gives a ribbon button to send the contents of email to OneNote. There is a step or two here which can be eliminated with this addin. This addin adds the capability of sending yourself email with a certain keyword in the subject and having Outlook automatically create a new page in OneNote's Unfiled Notes section when that mail item arrives. Outlook then deletes the email. It also allows power users to set the filter used for incoming mail items to trigger the code. It provides no UI for the user: "it just works." I also included the setup project since it is needed to create the registry key when executed. If you just want to install and use the addin, the Setup zip file is all you need. Exit all office apps and run setup.exe. BackgroundThis addin uses both the Outlook 2007 Object Model to work with the Outlook item and the OneNote 2007 XML API to add the page to OneNote. The OneNote 2007 XML API is documented here. The Outlook 2007 OM reference is here. The Design GoalsHere are my goals for this addin, driven almost entirely from the scenario I describe above:
Functionality I will not implement:
Using the codeBefore I even got to writing the code, I had to get my project to reference the Outlook 12 object model and the OneNote 12 API. I added a reference to both the COM libraries in my Visual Studio project. Knowing I would need some XML manipulation, I added a reference to System.XML. I wanted the filter for the subject line to be settable by the user. I did not want any UI to show with this addin, so I decided to create a registry key to store the filter. The casual user can use the default text string of "onon" - which should be easy to remember and type on a cell phone - and the power user can alter the registry key if needed. The only event I need from Outlook is the new mail notification event. public void OnStartupComplete(ref System.Array custom)
{
//register for the new mail event in Outlook
olApp.NewMail +=
new Microsoft.Office.Interop.Outlook.
ApplicationEvents_11_NewMailEventHandler(olApp_NewMail);
}
Then the application just waits for the new mail event to fire and checks to see if the inbound item (of IPM.Note only) matches the filter criteria. If so, the code looks through the existing OneNote heirarchy to find the UnfiledNotes section where it adds the body of the message as a page. Then it deletes the mail item. Points of InterestThere wasn't a lot to this addin. One interesting note is using the HTMLBody property of the Outlook mail item. Outlook supports rich and plain text mail formats as well as HTML. Initially, I used only the Body property of the email item: Some thanks are in order. The code for getting to the UnfiledNotes section was taken from the OneNote Sidebar gadget available on the Microsoft website. Henrieta Slugenova pointed out some limitations of this implementation during her testing. I incorporated them into the "Ideas for Improvement" below. And to David Rasmussen for the idea. He has a blog here. Ideas for ImprovementAdd UI to allow user to change the filter text. Allow user to set where in OneNote these emails are sent. Attachment and image support. Or, recreate this solution as a custom action for the Outlook Rules Wizard (where it seems to make more sense in some ways).HistoryArticle initially written in January 2007.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||