{"id":269,"date":"2008-05-25T20:13:59","date_gmt":"2008-05-25T20:13:59","guid":{"rendered":"http:\/\/dalelane.co.uk\/blog\/?p=269"},"modified":"2008-05-25T20:43:56","modified_gmt":"2008-05-25T20:43:56","slug":"custom-properties-in-outlook-mobile","status":"publish","type":"post","link":"https:\/\/dalelane.co.uk\/blog\/?p=269","title":{"rendered":"Custom properties in Outlook Mobile"},"content":{"rendered":"<p>As part of my plan to write a <a href=\"http:\/\/dalelane.co.uk\/blog\/?p=268\">location-based reminder app using Bluetooth devices<\/a>, I need a way to assign tasks to people, and people to specific Bluetooth device IDs. <\/p>\n<p>I&#8217;ve decided to do this using custom properties in Outlook Mobile &#8211; the default PIM that comes on all Windows Mobile smartphones and PDAs.  <\/p>\n<p>I&#8217;ve not used this API before, but after a little playing, I&#8217;m impressed with how straightforward it all is.  <\/p>\n<p>The idea is that items in the Outlook Mobile PIM have pre-defined properties &#8211; so Contacts have fields such as &#8216;First Name&#8217;, or &#8216;Postcode&#8217;. But you can programmatically add new fields, and then store whatever you want in them. <\/p>\n<p>For <a href=\"http:\/\/dalelane.co.uk\/blog\/?p=268\">my purposes<\/a>, I can add a &#8220;Bluetooth Device IDs&#8221; property to Contact items in my address book. I can also add pointers to Contact items to Task items in my to do list. <\/p>\n<p>As this is just meant as a quick hack \/ proof-of-concept, I&#8217;m doing this in C#. The code looks something like this: <\/p>\n<p><!--more--><\/p>\n<pre style=\"border: thin solid silver; background-color: #eeeeee; padding: 0.7em\">using Microsoft.WindowsMobile.PocketOutlook; \r\n\r\npublic void SetContactCustomProperty(Contact outlookContact,  \r\n                                     string customPropertyName,  \r\n                                     string customPropertyValue) \r\n{ \r\n  if ((outlookContact.Properties.Contains(customPropertyName) == false) ||  \r\n      (outlookContact.Properties[customPropertyName] == null)) \r\n  { \r\n    outlookContact.Properties.Add(customPropertyName, typeof(string)); \r\n  } \r\n\r\n  outlookContact.Properties[customPropertyName] = customPropertyValue; \r\n\r\n  outlookContact.Update(); \r\n} \r\n\r\npublic string GetCustomContactProperty(Contact outlookContact,  \r\n                                       string customPropertyName) \r\n{ \r\n  if (outlookContact.Properties.Contains(customPropertyName) == false) \r\n  { \r\n    return null; \r\n  } \r\n\r\n  return outlookContact.Properties[customPropertyName]; \r\n}<\/pre>\n<p>For my purposes, I want to store strings, but it&#8217;s not limited to that &#8211; you can store other data types. <\/p>\n<h3>Limitations<\/h3>\n<p>I&#8217;ve come across a couple of limitations. <\/p>\n<p>Firstly,<strong> custom properties do not show up in the Outlook Mobile apps<\/strong>. They&#8217;re stored in the underlying PIM database, but they&#8217;re not exposed to the user by the core PIM apps.  <\/p>\n<p>In the full desktop Outlook, you can easily modify Forms to add controls for custom fields, and there is also a &#8216;View all fields&#8217; view as a last-resort. But you can&#8217;t do this in Outlook Mobile.  <\/p>\n<p>It&#8217;s a shame &#8211; I wanted the user to be able to specify Bluetooth Device IDs from within the Address Book, and to be able to assign tasks to people from within the Task list. But to do this, I&#8217;m gonna need to write a DLL in C++ to extend the core PIM apps. I&#8217;ve <a href=\"http:\/\/dalelane.co.uk\/blog\/?p=175\">done this before<\/a>, but it&#8217;s fiddly and time-consuming and I&#8217;m not in the mood to fight with that tonight.  <\/p>\n<p>For now I&#8217;m just gonna have to create a new stand-alone interface for managing and displaying the pairings. A bit clunky. \ud83d\ude41 <\/p>\n<p>Secondly (and more annoyingly!), <strong>custom properties are not sync&#8217;ed<\/strong> to the desktop Outlook by ActiveSync. I&#8217;ve experimented with making changes on Outlook Mobile, but none of these have shown up in the desktop Outlook.  <\/p>\n<p>I wanted the user to be able to maintain assignments of people to mobiles, and people to tasks from their desktop. But it looks like to manage that, I&#8217;d have to write my own ActiveSync conduit to manually synchronise any custom fields. This is uber-fiddly, and I really can&#8217;t be bothered to fight with that.  <\/p>\n<p>So for now, this is going to be a mobile-only application. It&#8217;s not a major problem &#8211; custom properties in Outlook Mobile are persisted fine after synchronisation of changes on either desktop or mobile. But even so&#8230; desktop Outlook has support for custom fields, Outlook Mobile has support for custom properties&#8230; it&#8217;d be really nice if ActiveSync could sync between the two! <\/p>\n","protected":false},"excerpt":{"rendered":"<p>As part of my plan to write a location-based reminder app using Bluetooth devices, I need a way to assign tasks to people, and people to specific Bluetooth device IDs. I&#8217;ve decided to do this using custom properties in Outlook Mobile &#8211; the default PIM that comes on all Windows Mobile smartphones and PDAs. I&#8217;ve [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[20,206,205,21,203,204,19,43],"class_list":["post-269","post","type-post","status-publish","format-standard","hentry","category-code","tag-net","tag-activesync","tag-compact-framework","tag-dotnet","tag-outlook","tag-outlook-mobile","tag-windows-mobile","tag-windowsmobile"],"_links":{"self":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/269","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=269"}],"version-history":[{"count":0,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/269\/revisions"}],"wp:attachment":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=269"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=269"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=269"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}