<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>mstehle: The CDOs and CDONTS of Messaging Development</title><link>http://blogs.msdn.com/mstehle/default.aspx</link><description>Dedicated to supporting developers writing code against Outlook and Exchange.  We'll explore the API's, debunk myths, and get a better understanding of Product Support in general.</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>FYI: Can’t use Exchange Impersonation with GetUserOofSettings, SetUserOofSettings, or GetUserAvailability</title><link>http://blogs.msdn.com/mstehle/archive/2009/06/24/fyi-can-t-use-exchange-impersonation-with-getuseroofsettings-setuseroofsettings-or-getuseravailability.aspx</link><pubDate>Wed, 24 Jun 2009 20:45:16 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9802095</guid><dc:creator>mstehle</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/mstehle/comments/9802095.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mstehle/commentrss.aspx?PostID=9802095</wfw:commentRss><wfw:comment>http://blogs.msdn.com/mstehle/rsscomments.aspx?PostID=9802095</wfw:comment><description>&lt;p&gt;&lt;font size="1"&gt;I kept forgetting about this so maybe blogging it will help me remember.&amp;#160; As &lt;/font&gt;&lt;a href="http://social.technet.microsoft.com/Forums/en-US/exchangesvrdevelopment/thread/3bede794-9940-4635-a687-24c05b313f8b/"&gt;&lt;font size="1"&gt;this thread&lt;/font&gt;&lt;/a&gt;&lt;font size="1"&gt; confirms – you can’t call GetUserOofSettings, SetUserOofSettings, or GetUserAvailability when using Exchange Impersonation.&amp;#160; If you try to do this you’ll get an error that the Service Account is not the mailbox owner.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="1"&gt;&lt;/font&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9802095" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mstehle/archive/tags/FYI/default.aspx">FYI</category><category domain="http://blogs.msdn.com/mstehle/archive/tags/Exchange+Web+Services/default.aspx">Exchange Web Services</category><category domain="http://blogs.msdn.com/mstehle/archive/tags/DevMsgTeam/default.aspx">DevMsgTeam</category><category domain="http://blogs.msdn.com/mstehle/archive/tags/Exchange+Web+Services+Managed+API/default.aspx">Exchange Web Services Managed API</category></item><item><title>Exchange API Team Blog: Exchange Impersonation vs. Delegate Access…</title><link>http://blogs.msdn.com/mstehle/archive/2009/06/16/exchange-api-team-blog-exchange-impersonation-vs-delegate-access.aspx</link><pubDate>Tue, 16 Jun 2009 14:34:14 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9762435</guid><dc:creator>mstehle</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/mstehle/comments/9762435.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mstehle/commentrss.aspx?PostID=9762435</wfw:commentRss><wfw:comment>http://blogs.msdn.com/mstehle/rsscomments.aspx?PostID=9762435</wfw:comment><description>&lt;p&gt;The Exchange API team has a new &lt;a href="http://blogs.msdn.com/exchangedev/archive/2009/06/15/exchange-impersonation-vs-delegate-access.aspx"&gt;post&lt;/a&gt; to explaining the differences between using Exchange Impersonation vs. Delegate Access to access an Exchange mailbox using Exchange Web Services.&amp;#160; I’ve seen first hand that there is a gap in understanding the difference between the two and when to use one versus the other.&amp;#160; This post goes a long way to address some of the confusion.&lt;/p&gt;  &lt;p&gt;An important note that some people miss is the differentiation between Windows and Exchange impersonation – they’re not the same thing and more importantly, they aren’t even related…&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;“Exchange Impersonation is different than Windows Impersonation. Windows Impersonation is an operating system concept that requires you to set Kerberos constrained delegation. Exchange Impersonation is a simpler authorization mechanism that is designed for use only within Exchange Web Services (EWS). For more information about Windows Impersonation, see &lt;/em&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/aa376391(VS.85).aspx"&gt;&lt;em&gt;Client Impersonation&lt;/em&gt;&lt;/a&gt;&lt;em&gt; on MSDN.”&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Conversely, the posts describes delegate access as…&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;“Delegate access is used in scenarios in which there needs to be a one-to-one relationship between users. One common application of delegate access is the sharing of calendars between users, such as when an admin manages an executive’s calendar, or a when handful of individuals working on a project need to coordinate calendars…&lt;/em&gt;&lt;/p&gt;    &lt;p&gt;&lt;em&gt;…Individual users can grant and remove delegate access to their own mailboxes through several mailbox clients, such as Microsoft Outlook, Outlook Web Access, or Exchange Web Services-based clients. A mailbox owner does not need administrator rights to grant another user delegate access to their mailbox.”&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;…To be clear, delegate access &lt;u&gt;can&lt;/u&gt; be granted by an administrator on an entire mailbox (but not to specific folders within the mailbox) using the &lt;a href="http://technet.microsoft.com/en-us/library/bb124097.aspx"&gt;Add-MailboxPermission&lt;/a&gt; cmdlet but as the above statement points out individuals can also grant delegate access for other users to access specific folders in their mailbox or the entire mailbox.&lt;/p&gt;  &lt;p&gt;A major difference between impersonation and delegation is that as far as Exchange Web Services and Outlook Web Access are concerned there is no way to assign a single delegate access to multiple mailboxes expect by establishing the delegate relationship for each individual mailbox.&amp;#160; I’ve talked about this &lt;a href="http://blogs.msdn.com/mstehle/archive/2007/09/07/kb-exchange-web-services-does-not-honor-inherited-permissions-from-server-level-objects.aspx"&gt;before&lt;/a&gt;, the Exchange team describes it this way…&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;“For delegate access, there is no option to set up a single delegate for multiple mailboxes. A relationship must be established for each user who needs to access a given mailbox…&lt;/em&gt;&lt;/p&gt;    &lt;p&gt;&lt;em&gt;…You must explicitly grant delegate access for any new users who are added.”&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;…This is a great post and a worthwhile read but from working with many customers to help them understand these concepts, I’d like to add some additional information and emphasize some key points…&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Understanding the Requests&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;To emphasize a side point in the blog post there are &lt;u&gt;three&lt;/u&gt; methods of mailbox to access a mailbox: Exchange Impersonation, Delegate Access, and Direct Logon.&amp;#160; The article doesn’t provide examples of what the XML looks like in each type of access request using Exchange Web Services.&amp;#160; For understanding, I’ve provided them below…&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;strong&gt;Direct Logon&lt;/strong&gt;&lt;/p&gt;    &lt;p&gt;&amp;lt;GetFolder&amp;gt;     &lt;br /&gt;&amp;#160; &amp;lt;FolderShape&amp;gt;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;t:BaseShape&amp;gt;AllProperties&amp;lt;/t:BaseShape&amp;gt;      &lt;br /&gt;&amp;#160; &amp;lt;/FolderShape&amp;gt;      &lt;br /&gt;&amp;#160; &amp;lt;FolderIds&amp;gt;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;t:DistinguishedFolderId Id=&amp;quot;inbox&amp;quot;/&amp;gt;      &lt;br /&gt;&amp;#160; &amp;lt;/FolderIds&amp;gt;      &lt;br /&gt;&amp;lt;/GetFolder&amp;gt; &lt;/p&gt;    &lt;p&gt;&lt;strong&gt;Delegate Access&lt;/strong&gt;&lt;/p&gt;    &lt;p&gt;&amp;lt;GetFolder&amp;gt;     &lt;br /&gt;&amp;#160; &amp;lt;FolderShape&amp;gt;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;t:BaseShape&amp;gt;AllProperties&amp;lt;/t:BaseShape&amp;gt;      &lt;br /&gt;&amp;#160; &amp;lt;/FolderShape&amp;gt;      &lt;br /&gt;&amp;#160; &amp;lt;FolderIds&amp;gt;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;t:DistinguishedFolderId Id=&amp;quot;inbox&amp;quot;&amp;gt;      &lt;br /&gt;&lt;font color="#ff0000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;t:Mailbox&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;t:EmailAddress&amp;gt;        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;a href="mailto:someoneelse@contoso.com"&gt;&lt;font color="#ff0000"&gt;someoneelse@contoso.com&lt;/font&gt;&lt;/a&gt;      &lt;br /&gt;&lt;font color="#ff0000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/t:EmailAddress&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/t:Mailbox&amp;gt;        &lt;br /&gt;&lt;/font&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/t:DistinguishedFolderId&amp;gt;      &lt;br /&gt;&amp;#160; &amp;lt;/FolderIds&amp;gt;      &lt;br /&gt;&amp;lt;/GetFolder&amp;gt; &lt;/p&gt;    &lt;p&gt;&lt;strong&gt;Exchange Impersonation&lt;/strong&gt; &lt;/p&gt;    &lt;p&gt;&amp;lt;soap:Header&amp;gt;     &lt;br /&gt;&lt;font color="#ff0000"&gt;&amp;#160; &amp;lt;t:ExchangeImpersonation&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;t:ConnectingSID&amp;gt;        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;t:PrimarySmtpAddress&amp;gt;        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; someone@contoso.com        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/t:PrimarySmtpAddress&amp;gt;        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/t:ConnectingSID&amp;gt;        &lt;br /&gt;&amp;#160; &amp;lt;/t:ExchangeImpersonation&amp;gt;&lt;/font&gt;      &lt;br /&gt;&amp;lt;/soap:Header&amp;gt;      &lt;br /&gt;&amp;lt;soap:Body&amp;gt;      &lt;br /&gt;&amp;#160; &amp;lt;GetFolder&amp;gt;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;FolderShape&amp;gt;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;t:BaseShape&amp;gt;AllProperties&amp;lt;/t:BaseShape&amp;gt;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/FolderShape&amp;gt;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;FolderIds&amp;gt;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;t:DistinguishedFolderId Id=&amp;quot;inbox&amp;quot;/&amp;gt;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/FolderIds&amp;gt;      &lt;br /&gt;&amp;#160; &amp;lt;/GetFolder&amp;gt;      &lt;br /&gt;&amp;lt;/soap:Body&amp;gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;…The example above is for &lt;em&gt;explicit&lt;/em&gt; delegate access.&amp;#160; You can also access a mailbox using &lt;em&gt;implicit&lt;/em&gt; delegate access by specifying a FolderId which links to another mailbox.&amp;#160; All Ids returned by EWS embed their mailbox information in them so requesting them without explicitly specifying a mailbox will also work.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Putting It All Together&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;The terms used here come from the way Exchange Impersonation (also called &lt;a href="http://msdn.microsoft.com/en-us/library/aa579435.aspx"&gt;Server-to-Server or S2S Authentication&lt;/a&gt;) is explained in the Inside Exchange Web Services book.&amp;#160; The book describes three types of accounts that come into play when accessing a mailbox: the Service account, the Act As account, and the Mailbox account.&amp;#160; Understanding how these accounts are affected by different mailbox access types is important.&amp;#160; The Service account is the account used to generate the XML requests and authenticate to the virtual directory, the Act As account is the account which will be used to authorize actions taken against a mailbox, and the Mailbox account is the actual resource you are trying to access.&amp;#160; In the grid below suppose you have an EWS application which runs as a user called ApplicationAccount, here is how the different access types affect each account context…&lt;/p&gt;  &lt;table border="0" cellspacing="0" cellpadding="2" width="1112"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign="top" width="141"&gt;&lt;strong&gt;Access Type&lt;/strong&gt;&lt;/td&gt;        &lt;td valign="top" width="146"&gt;&lt;strong&gt;Service Account&lt;/strong&gt;&lt;/td&gt;        &lt;td valign="top" width="350"&gt;&lt;strong&gt;Act As Account&lt;/strong&gt;&lt;/td&gt;        &lt;td valign="top" width="473"&gt;&lt;strong&gt;Mailbox Account&lt;/strong&gt;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="141"&gt;Exchange Impersonation&lt;/td&gt;        &lt;td valign="top" width="146"&gt;ApplicationAccount&lt;/td&gt;        &lt;td valign="top" width="350"&gt;the impersonated account as specified in the &lt;a href="http://msdn.microsoft.com/en-us/library/aa565690.aspx"&gt;ExchangeImpersonation&lt;/a&gt; property of the request&lt;/td&gt;        &lt;td valign="top" width="473"&gt;any mailbox that the &lt;u&gt;Act As account&lt;/u&gt; has mailbox rights to through Add-MailboxPermission or through permissions granted through Outlook, OWA, or EWS directly on a mailbox folder.&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="141"&gt;Delegate Access&lt;/td&gt;        &lt;td valign="top" width="146"&gt;ApplicationAccount&lt;/td&gt;        &lt;td valign="top" width="350"&gt;always ApplicationAccount&lt;/td&gt;        &lt;td valign="top" width="473"&gt;any account or mailbox folder that &lt;u&gt;ApplicationAccount&lt;/u&gt; has mailbox rights to through Add-MailboxPermission or through permissions granted through Outlook, OWA, or EWS directly on a mailbox folder.&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="141"&gt;Direct Logon&lt;/td&gt;        &lt;td valign="top" width="146"&gt;ApplicationAccount&lt;/td&gt;        &lt;td valign="top" width="350"&gt;always ApplicationAccount&lt;/td&gt;        &lt;td valign="top" width="473"&gt;always ApplicationAccount&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9762435" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mstehle/archive/tags/Exchange+General/default.aspx">Exchange General</category><category domain="http://blogs.msdn.com/mstehle/archive/tags/Exchange+Web+Services/default.aspx">Exchange Web Services</category><category domain="http://blogs.msdn.com/mstehle/archive/tags/DevMsgTeam/default.aspx">DevMsgTeam</category><category domain="http://blogs.msdn.com/mstehle/archive/tags/Exchange+Web+Services+Managed+API/default.aspx">Exchange Web Services Managed API</category></item><item><title>FYI:  Issue with Windows 7 RC and VSTO…</title><link>http://blogs.msdn.com/mstehle/archive/2009/06/02/fyi-issue-with-windows-7-rc-and-vsto.aspx</link><pubDate>Tue, 02 Jun 2009 17:15:46 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9686004</guid><dc:creator>mstehle</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/mstehle/comments/9686004.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mstehle/commentrss.aspx?PostID=9686004</wfw:commentRss><wfw:comment>http://blogs.msdn.com/mstehle/rsscomments.aspx?PostID=9686004</wfw:comment><description>&lt;p&gt;The &lt;a href="http://blogs.msdn.com/vsto/archive/2009/05/07/issues-with-installing-vsto-projects-that-were-published-from-visual-studio-2008-on-windows-7-rc-saurabh-bhatia.aspx"&gt;VSTO team has a post&lt;/a&gt; which details an issue that you might see when trying to deploy a VSTO solution to Windows 7 RC.&amp;#160; The error message would be…&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;“The required version of the .NET Framework is not installed on this computer”&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;As the blog post points out, the appropriate teams are aware of the issue and plan to address it by RTM of Windows 7.&amp;#160; Additionally they provide a workaround in the meantime.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9686004" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mstehle/archive/tags/DevMsgTeam/default.aspx">DevMsgTeam</category><category domain="http://blogs.msdn.com/mstehle/archive/tags/VSTO/default.aspx">VSTO</category></item><item><title>FYI: Exchange 2007 SP2 Announced…</title><link>http://blogs.msdn.com/mstehle/archive/2009/06/01/fyi-exchange-2007-sp2-announced.aspx</link><pubDate>Mon, 01 Jun 2009 13:35:09 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9677573</guid><dc:creator>mstehle</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/mstehle/comments/9677573.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mstehle/commentrss.aspx?PostID=9677573</wfw:commentRss><wfw:comment>http://blogs.msdn.com/mstehle/rsscomments.aspx?PostID=9677573</wfw:comment><description>&lt;p&gt;The Exchange team &lt;a href="http://msexchangeteam.com/archive/2009/05/11/451281.aspx"&gt;announced&lt;/a&gt; the upcoming service pack for Exchange 2007 recently.&amp;#160; The primary focus of this service pack is preparing Exchange 2007 for interoperability with Exchange 2010 but there are also fixes and changes to existing components and technologies that make this update worth installing when it comes out.&amp;#160; Here are some developer related points of interest that were announced:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;“&lt;b&gt;Exchange Volume Snapshot Backup Functionality &lt;/b&gt;&lt;b&gt;- &lt;/b&gt;A new backup plug-in has been added to the product that will enable customers to create Exchange backups when a backup is invoked through the Windows Server 2008 Backup tool. Exchange Server 2007 didn't have this capability on Windows Server 2008 and additional solutions were required to perform this task.&lt;/p&gt;    &lt;p&gt;&lt;b&gt;Named Properties cmdlets&lt;/b&gt; - SP2 enables Exchange administrators to monitor their named property usage per database.”&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;…Both of these are most useful to developers as debugging tools but they are valuable nonetheless.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9677573" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mstehle/archive/tags/Exchange+General/default.aspx">Exchange General</category><category domain="http://blogs.msdn.com/mstehle/archive/tags/DevMsgTeam/default.aspx">DevMsgTeam</category></item><item><title>INFO: EWS Tips and Tricks Links…</title><link>http://blogs.msdn.com/mstehle/archive/2009/05/29/info-ews-tips-and-tricks-links.aspx</link><pubDate>Fri, 29 May 2009 17:28:10 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9655724</guid><dc:creator>mstehle</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/mstehle/comments/9655724.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mstehle/commentrss.aspx?PostID=9655724</wfw:commentRss><wfw:comment>http://blogs.msdn.com/mstehle/rsscomments.aspx?PostID=9655724</wfw:comment><description>&lt;p&gt;MVP Henning Krause has some good posts about various different tips and tricks with EWS that are worth looking at…&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.infinitec.de/post/2009/04/13/Searching-a-meeting-with-a-specific-UID-using-Exchange-Web-Services-2007.aspx"&gt;Searching a meeting with a specific UID using Exchange Web Services 2007&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.infinitec.de/post/2009/04/13/Resolving-the-primary-email-address-with-Exchange-WebServices-ResolveNames-operation.aspx"&gt;Resolving the primary email address with Exchange WebServices ResolveNames operation&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.infinitec.de/post/2009/03/27/Saving-custom-data-on-Exchange-elements-with-The-Exchange-WebServices.aspx"&gt;Saving custom data on Exchange elements with The Exchange WebServices&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;…The UID and custom data posts are particularly insightful.&amp;#160; A key takeaway of the UID post is that “schema properties” or “first-class properties” such as UID often are calculated from or directly relate to “extended properties” or “MAPI properties”.&amp;#160; Often times you can workaround a limitation of schema properties by using the related extended property as Henning does with UID and GlobalObjectID.&amp;#160; In the saving custom data post, Henning gives some good background on named properties as well as why choosing the right property set is important…&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;&amp;quot;One property set is of particular interest, namely the one called PublicStrings. All custom properties created with Outlook are stored in this set. If a custom property is designed to be used by custom Outlook formulas, the developer must choose this property set. In any other case, it is better to create a random GUID and use that property set to prevent collisions with other applications.”&lt;/em&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9655724" width="1" height="1"&gt;</description></item><item><title>FYI: In Outlook 2010 Exchange Client Extensions Are Gone…</title><link>http://blogs.msdn.com/mstehle/archive/2009/05/26/fyi-in-outlook-2010-exhcange-client-extensions-are-gone.aspx</link><pubDate>Tue, 26 May 2009 13:32:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9641427</guid><dc:creator>mstehle</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/mstehle/comments/9641427.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mstehle/commentrss.aspx?PostID=9641427</wfw:commentRss><wfw:comment>http://blogs.msdn.com/mstehle/rsscomments.aspx?PostID=9641427</wfw:comment><description>&lt;P&gt;On the Outlook team blog it was &lt;A href="http://blogs.msdn.com/outlook/archive/2009/05/04/announcing-the-deprecation-of-exchange-client-extensions.aspx" mce_href="http://blogs.msdn.com/outlook/archive/2009/05/04/announcing-the-deprecation-of-exchange-client-extensions.aspx"&gt;announced&lt;/A&gt; recently that Exchange Client Extensions (ECEs) will not work with Outlook 2010.&amp;nbsp; This shouldn’t come as a big surprise, they haven’t been a primary extensibility model for Outlook since Outlook 97-98 days.&amp;nbsp; However, many Outlook developers have continued to maintain their ECEs and Microsoft supports them to work on Outlook versions up to Outlook 2007.&amp;nbsp; Here are the suggestions from the blog post about how to move forward…&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;EM&gt;“To redesign your solution, you should consider the following options:&lt;/EM&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;EM&gt;Rewrite your ECE as a COM Add-in using native or managed code. Unlike ECEs, an add-in represents a strategic extensibility technology that is fully supported in Outlook 2010. Using an Outlook add-in, you can build &lt;/EM&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/bb226713.aspx" mce_href="http://msdn.microsoft.com/en-us/library/bb226713.aspx"&gt;&lt;EM&gt;Outlook form regions&lt;/EM&gt;&lt;/A&gt;&lt;EM&gt; and extend the &lt;/EM&gt;&lt;A href="http://msdn.microsoft.com/en-us/office/aa905530.aspx" mce_href="http://msdn.microsoft.com/en-us/office/aa905530.aspx"&gt;&lt;EM&gt;Office Fluent User Interface&lt;/EM&gt;&lt;/A&gt;&lt;EM&gt;. For additional information, please visit the &lt;/EM&gt;&lt;A href="http://msdn.microsoft.com/en-us/office/aa905455.aspx" mce_href="http://msdn.microsoft.com/en-us/office/aa905455.aspx"&gt;&lt;EM&gt;Outlook Developer Portal&lt;/EM&gt;&lt;/A&gt;&lt;EM&gt; on MSDN. &lt;/EM&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;EM&gt;Rewrite your ECE as a Windows service application using native code and MAPI. If you are writing a Windows service application, you must use MAPI to access Outlook items rather than the Outlook object model.”&lt;/EM&gt; &lt;/LI&gt;&lt;/UL&gt;&lt;/BLOCKQUOTE&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9641427" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mstehle/archive/tags/Outlook+General/default.aspx">Outlook General</category><category domain="http://blogs.msdn.com/mstehle/archive/tags/DevMsgTeam/default.aspx">DevMsgTeam</category><category domain="http://blogs.msdn.com/mstehle/archive/tags/Outlook+Add-Ins/default.aspx">Outlook Add-Ins</category></item><item><title>FYI: Unlike Exchange 2007, Exchange 2010 will *not* ship a 32-bit version</title><link>http://blogs.msdn.com/mstehle/archive/2009/05/21/fyi-unlike-exchange-2007-exchange-2010-will-not-ship-a-32-bit-version.aspx</link><pubDate>Thu, 21 May 2009 19:06:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9634182</guid><dc:creator>mstehle</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/mstehle/comments/9634182.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mstehle/commentrss.aspx?PostID=9634182</wfw:commentRss><wfw:comment>http://blogs.msdn.com/mstehle/rsscomments.aspx?PostID=9634182</wfw:comment><description>&lt;P&gt;The Exchange team &lt;A href="http://msexchangeteam.com/archive/2009/05/19/451366.aspx" mce_href="http://msexchangeteam.com/archive/2009/05/19/451366.aspx"&gt;announced&lt;/A&gt; that Exchange 2010 will not have a 32-bit version – not even for evaluations.&amp;nbsp; The post focuses on mainly the non-developer related impact of this change.&amp;nbsp; The key points for developers are:&lt;/P&gt;
&lt;P&gt;&amp;gt; Applications that automate Exchange cmdlets locally will need to be compiled for 64-bit.&lt;/P&gt;
&lt;P&gt;&amp;gt; 32-bit or 64-bit applications could leverage the remote Powershell capabilities in Powershell 2.0 to invoke the Exchange cmdlets remotely.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9634182" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mstehle/archive/tags/FYI/default.aspx">FYI</category><category domain="http://blogs.msdn.com/mstehle/archive/tags/Exchange+General/default.aspx">Exchange General</category><category domain="http://blogs.msdn.com/mstehle/archive/tags/Exchange+Management+Shell/default.aspx">Exchange Management Shell</category><category domain="http://blogs.msdn.com/mstehle/archive/tags/DevMsgTeam/default.aspx">DevMsgTeam</category></item><item><title>FYI: The Exchange Web Services Managed API is here!</title><link>http://blogs.msdn.com/mstehle/archive/2009/04/20/fyi-the-exchange-web-services-managed-api-is-here.aspx</link><pubDate>Mon, 20 Apr 2009 15:15:51 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9556799</guid><dc:creator>mstehle</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/mstehle/comments/9556799.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mstehle/commentrss.aspx?PostID=9556799</wfw:commentRss><wfw:comment>http://blogs.msdn.com/mstehle/rsscomments.aspx?PostID=9556799</wfw:comment><description>&lt;p&gt;As you might have seen, we &lt;a href="http://blogs.msdn.com/exchangedev/"&gt;announced&lt;/a&gt; last week that the Exchange Web Services Managed API is now available as a &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=a8c9d043-c66c-4971-9459-8d1df1608c8b&amp;amp;displaylang=en"&gt;beta download&lt;/a&gt;.&amp;#160; I’ve been working with the API internally for about a year now and I must say, if you are writing .NET code that uses Exchange Web Services there’s no better way to do it.&amp;#160; I’ve been working on an Exchange browser application, similar to MFCMAPI which started out leveraging the &lt;a href="http://msdn.microsoft.com/en-us/library/bb402321.aspx"&gt;auto-generated proxy classes&lt;/a&gt;.&amp;#160; Switching this project over to the EWS Managed API cut down &lt;em&gt;hundreds&lt;/em&gt; of lines of code and improved the readability and organization of the code immensely.&amp;#160; (Stay tuned for more information on this project…)&lt;/p&gt;  &lt;p&gt;From &lt;a href="http://msdn.microsoft.com/en-us/library/dd637749.aspx"&gt;David Claux’s introduction&lt;/a&gt;:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;“The EWS Managed API is a fully object-oriented API that provides the experience developers have come to expect from Visual Studio and the Microsoft .NET Framework. Built on the EWS XML protocol, it provides an easy-to-learn, easy–to-use, and easy-to-maintain .NET interface to Exchange Web Services that both beginner and advanced developers will find to be an improvement over autogenerated proxies.&lt;/em&gt;&lt;/p&gt;    &lt;p&gt;&lt;em&gt;Although the EWS Managed API is a new API (in the sense that it is a new .NET assembly that developers have to explicitly reference in their applications), it is important to understand that &lt;strong&gt;we are not replacing the EWS protocol&lt;/strong&gt;. The EWS Managed API is just a complement to EWS for .NET developers. This means that &lt;strong&gt;your prior investments are safe&lt;/strong&gt;. Whether you are using raw XML (if you are a Javascript developer, for example) or autogenerated proxies (on Windows or other operating systems) to talk to EWS, your existing EWS applications will continue to work. The EWS protocol is still the future of Exchange development; all new features will continue to be added to the EWS protocol, and will also be exposed in the EWS Managed API.”&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;The API at it’s simplest is just a set of proxy classes for interacting with Exchange – they still generate the same Exchange Web Services SOAP XML that the auto-generated proxy classes do or that your code that doesn’t use proxy classes do.&amp;#160; The difference is that this API is easy to use, understand, and has some additional business logic included.&amp;#160; The release of this API doesn’t change the support or our recommendations towards use of Exchange Web Services in their raw form.&lt;/p&gt;  &lt;p&gt;Here are Matt’s three rules for getting started:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Check out &lt;a href="http://msdn.microsoft.com/en-us/library/dd637749.aspx"&gt;David Claux’s introduction&lt;/a&gt; for the API on MSDN as well as the &lt;a href="http://msdn.microsoft.com/en-us/library/dd633696.aspx"&gt;“Working with…” section&lt;/a&gt; of the MSDN reference. &lt;/li&gt;    &lt;li&gt;Don’t confuse the &lt;a href="http://msdn.microsoft.com/en-us/library/bb402321.aspx"&gt;Exchange Web Services Managed Reference&lt;/a&gt; with the &lt;a href="http://msdn.microsoft.com/en-us/library/dd635461.aspx"&gt;EWS Managed API Reference&lt;/a&gt;.&amp;#160; The Exchange Web Services Managed Reference in the MSDN is reference of the auto-generated proxy classes. &lt;/li&gt;    &lt;li&gt;For the sake of my sanity &lt;strong&gt;&lt;em&gt;&lt;u&gt;please don’t start calling this the EWS MAPI&lt;/u&gt;&lt;/em&gt;&lt;/strong&gt; – it’s the EWS Managed API, the EWS API, the EWS Client API, &lt;em&gt;The&lt;/em&gt; API, Managed EWS, anything you want that doesn’t involve acronyms shared with other Exchange APIs.&amp;#160; (I guess I should be happy they didn’t call it EWS CDO, right?) &lt;/li&gt; &lt;/ol&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9556799" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mstehle/archive/tags/Exchange+Web+Services/default.aspx">Exchange Web Services</category><category domain="http://blogs.msdn.com/mstehle/archive/tags/DevMsgTeam/default.aspx">DevMsgTeam</category><category domain="http://blogs.msdn.com/mstehle/archive/tags/Exchange+Web+Services+Managed+API/default.aspx">Exchange Web Services Managed API</category></item><item><title>OOM.NET: Like a good standup comic – use scope and have good timing…</title><link>http://blogs.msdn.com/mstehle/archive/2009/02/17/oom-net-like-a-good-standup-comic-use-scope-and-have-good-timing.aspx</link><pubDate>Tue, 17 Feb 2009 15:55:16 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9427731</guid><dc:creator>mstehle</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/mstehle/comments/9427731.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mstehle/commentrss.aspx?PostID=9427731</wfw:commentRss><wfw:comment>http://blogs.msdn.com/mstehle/rsscomments.aspx?PostID=9427731</wfw:comment><description>&lt;p&gt;Recently, I was helping someone with a Outlook item leak type issue involving a Task FormRegion.&amp;#160; The symptom was that after opening a task, closing it, and reopening the item they were getting the infamous error message, “COM object that has been separated from its underlying RCW cannot be used.”&amp;#160; They were familiar with some of the issues discussed here and knew to call &lt;em&gt;ReleaseCOMObject()&lt;/em&gt; on objects as they were done with them.&amp;#160; However, that is the only part of proper Outlook coding with .NET – you need to use scope and have good timing when you lay out .NET classes that handle events and use Outlook objects.&amp;#160; The following class is a simple example of that scope and timing…&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Scope&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;As I pointed out in &lt;a href="http://blogs.msdn.com/mstehle/archive/2007/12/06/oom-net-part-1-introduction-why-events-stop-firing.aspx" target="_blank"&gt;my original OOM.NET post&lt;/a&gt;, you need to consider the scope of the objects whose events you listen to.&amp;#160; The key is not to call &lt;em&gt;ReleaseCOMObject()&lt;/em&gt; on an item while you are still listening to events from it.&amp;#160; In the class below, notice that &lt;em&gt;_task&lt;/em&gt; is defined at the module level so that as long as the instance of &lt;em&gt;TaskRegion&lt;/em&gt; is alive and listening to the &lt;em&gt;Write()&lt;/em&gt; event &lt;em&gt;_task&lt;/em&gt; will not go out of scope and get garbage collected by the CLR.&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Timing&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;It seems like there is a general understanding now that Outlook objects need to be released.&amp;#160; Additionally, you must &lt;strong&gt;*always decrement the event handlers that you add*&lt;/strong&gt;.&amp;#160; However, the humor in a good joke is not just the punch line but also good timing – you have to be strategic about &lt;em&gt;when&lt;/em&gt; to call &lt;em&gt;ReleaseCOMObject() &lt;/em&gt;and &lt;em&gt;when&lt;/em&gt; to decrement the event handler.&amp;#160; Since this is a FormRegion class I’m utilizing the &lt;em&gt;FormRegionShowing&lt;/em&gt; event to initialize &lt;em&gt;_task&lt;/em&gt; and add the event handler and I use &lt;em&gt;FormRegionClosed&lt;/em&gt; to remove the event handler and release &lt;em&gt;_task&lt;/em&gt;.&amp;#160; In a simple item wrapper class you might use the constructor and a dispose method in the same way.&amp;#160; The goal is not call &lt;em&gt;ReleaseCOMObject()&lt;/em&gt; until the events are unhooked, that way the COM object become separated from your RCW that is still trying to handle events.&lt;/p&gt;  &lt;p&gt;&lt;em&gt;…&lt;strong&gt;NOTE – &lt;/strong&gt;I’m also employing &lt;a href="http://blogs.msdn.com/pcreehan/archive/2008/08/07/form-region-leak-in-visual-studio-tools-for-office-2008-v3-template.aspx" target="_blank"&gt;Patrick’s fix&lt;/a&gt; in FormRegionInitializing for a FormRegion specific leak scenario…&lt;/em&gt;&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;partial class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;TaskRegion
&lt;/span&gt;{
    Outlook.&lt;span style="color: #2b91af"&gt;TaskItem &lt;/span&gt;_task = &lt;span style="color: blue"&gt;null&lt;/span&gt;;

    &lt;span style="color: blue"&gt;#region &lt;/span&gt;Form Region Factory

    [Microsoft.Office.Tools.Outlook.&lt;span style="color: #2b91af"&gt;FormRegionMessageClass
        &lt;/span&gt;(Microsoft.Office.Tools.Outlook.&lt;span style="color: #2b91af"&gt;FormRegionMessageClassAttribute&lt;/span&gt;.Task)]
    [Microsoft.Office.Tools.Outlook.&lt;span style="color: #2b91af"&gt;FormRegionName
        &lt;/span&gt;(&lt;span style="color: #a31515"&gt;&amp;quot;ReleaseTaskRegion.TaskRegion&amp;quot;&lt;/span&gt;)]
    &lt;span style="color: blue"&gt;public partial class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;TaskRegionFactory
    &lt;/span&gt;{
        &lt;span style="color: green"&gt;// Occurs before the form region is initialized.
        // To prevent the form region from appearing, set e.Cancel to true.
        // Use e.OutlookItem to get a reference to the current Outlook item.
        &lt;/span&gt;&lt;span style="color: blue"&gt;private void &lt;/span&gt;TaskRegionFactory_FormRegionInitializing(&lt;span style="color: blue"&gt;object &lt;/span&gt;sender,
            Microsoft.Office.Tools.Outlook.&lt;span style="color: #2b91af"&gt;FormRegionInitializingEventArgs &lt;/span&gt;e)
        {
            &lt;span style="color: #2b91af"&gt;Marshal&lt;/span&gt;.ReleaseComObject(e.OutlookItem);
        }
    }

    &lt;span style="color: blue"&gt;#endregion

    &lt;/span&gt;&lt;span style="color: green"&gt;// Occurs before the form region is displayed.
    // Use this.OutlookItem to get a reference to the current Outlook item.
    // Use this.OutlookFormRegion to get a reference to the form region.
    &lt;/span&gt;&lt;span style="color: blue"&gt;private void &lt;/span&gt;TaskRegion_FormRegionShowing(&lt;span style="color: blue"&gt;object &lt;/span&gt;sender, System.&lt;span style="color: #2b91af"&gt;EventArgs &lt;/span&gt;e)
    {
        _task = &lt;span style="color: blue"&gt;this&lt;/span&gt;.OutlookItem &lt;span style="color: blue"&gt;as &lt;/span&gt;Outlook.&lt;span style="color: #2b91af"&gt;TaskItem&lt;/span&gt;;

        _task.Write += &lt;span style="color: blue"&gt;new &lt;/span&gt;Outlook.&lt;span style="color: #2b91af"&gt;ItemEvents_10_WriteEventHandler&lt;/span&gt;(_task_Write);
    }

    &lt;span style="color: blue"&gt;private void &lt;/span&gt;_task_Write(&lt;span style="color: blue"&gt;ref bool &lt;/span&gt;Cancel)
    {
        System.Diagnostics.&lt;span style="color: #2b91af"&gt;Debug&lt;/span&gt;.WriteLine(&lt;span style="color: #a31515"&gt;&amp;quot;Write fired!&amp;quot;&lt;/span&gt;);
    }

    &lt;span style="color: green"&gt;// Occurs when the form region is closed.
    // Use this.OutlookItem to get a reference to the current Outlook item.
    // Use this.OutlookFormRegion to get a reference to the form region.
    &lt;/span&gt;&lt;span style="color: blue"&gt;private void &lt;/span&gt;TaskRegion_FormRegionClosed(&lt;span style="color: blue"&gt;object &lt;/span&gt;sender, System.&lt;span style="color: #2b91af"&gt;EventArgs &lt;/span&gt;e)
    {
        _task.Write -= &lt;span style="color: blue"&gt;new &lt;/span&gt;Outlook.&lt;span style="color: #2b91af"&gt;ItemEvents_10_WriteEventHandler&lt;/span&gt;(_task_Write);

        System.Runtime.InteropServices.&lt;span style="color: #2b91af"&gt;Marshal&lt;/span&gt;.ReleaseComObject(_task);
    }
}&lt;/pre&gt;

&lt;p&gt;&lt;em&gt;…This post is a continuation of my efforts to document common issues I’ve seen when .NET programmers write solutions with Outlook’s object model – be they separate executables, VSTO Add-ins, or Outlook FormRegions. To see all the posts in this series check out my posts with the &lt;/em&gt;&lt;a href="http://blogs.msdn.com/&amp;hellip;This post is a continuation of my efforts to document common issues I&amp;rsquo;ve seen when .NET programmers write solutions with Outlook&amp;rsquo;s object model &amp;ndash; be they separate executables, VSTO Add-ins, or Outlook FormRegions.  To see all the posts in this series check out my posts with the OOM.NET tag&amp;hellip;"&gt;&lt;em&gt;OOM.NET&lt;/em&gt;&lt;/a&gt;&lt;em&gt; tag…&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;…To check out more blog posts from Microsoft’s Messaging Developer Support team which supports Outlook, Exchange, and other email-related development using Microsoft APIs check out the &lt;a href="http://blogs.msdn.com/search/Searchrss.aspx?tag=DevMsgTeam"&gt;DevMsgTeam&lt;/a&gt; tag across all MSDN blogs…&lt;/em&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9427731" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mstehle/archive/tags/Outlook+Object+Model/default.aspx">Outlook Object Model</category><category domain="http://blogs.msdn.com/mstehle/archive/tags/OOM.NET/default.aspx">OOM.NET</category><category domain="http://blogs.msdn.com/mstehle/archive/tags/DevMsgTeam/default.aspx">DevMsgTeam</category><category domain="http://blogs.msdn.com/mstehle/archive/tags/VSTO/default.aspx">VSTO</category></item><item><title>OOM.NET: Some day we’ll look back and laugh at the “Good Ole’ Days of Item Leaks”…</title><link>http://blogs.msdn.com/mstehle/archive/2009/02/17/oom-net-some-day-we-ll-look-back-and-laugh-at-the-good-ole-days-of-item-leaks.aspx</link><pubDate>Tue, 17 Feb 2009 15:40:23 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9427702</guid><dc:creator>mstehle</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/mstehle/comments/9427702.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mstehle/commentrss.aspx?PostID=9427702</wfw:commentRss><wfw:comment>http://blogs.msdn.com/mstehle/rsscomments.aspx?PostID=9427702</wfw:comment><description>&lt;p&gt;Misha Shneerson, a senior developer on the VSTO team, has a &lt;a href="http://blogs.msdn.com/mshneer/archive/2008/10/28/better-eventing-support-in-clr-4-0-using-nopia-support.aspx" target="_blank"&gt;great post giving us hope&lt;/a&gt; in the next version of the .NET framework and the 4.0 CLR.&amp;#160; The feature name Misha uses gives it away, “NOPIA” means no interop assemblies!&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;em&gt;…This post is a continuation of my efforts to document common issues I’ve seen when .NET programmers write solutions with Outlook’s object model – be they separate executables, VSTO Add-ins, or Outlook FormRegions. To see all the posts in this series check out my posts with the &lt;/em&gt;&lt;a href="&amp;hellip;This post is a continuation of my efforts to document common issues I&amp;rsquo;ve seen when .NET programmers write solutions with Outlook&amp;rsquo;s object model &amp;ndash; be they separate executables, VSTO Add-ins, or Outlook FormRegions.  To see all the posts in this series check out my posts with the OOM.NET tag&amp;hellip;" target="_blank"&gt;&lt;em&gt;OOM.NET&lt;/em&gt;&lt;/a&gt;&lt;em&gt; tag…&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;…To check out more blog posts from Microsoft’s Messaging Developer Support team which supports Outlook, Exchange, and other email-related development using Microsoft APIs check out the &lt;a href="http://blogs.msdn.com/search/Searchrss.aspx?tag=DevMsgTeam" target="_blank"&gt;DevMsgTeam&lt;/a&gt; tag across all MSDN blogs…&lt;/em&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9427702" width="1" height="1"&gt;</description></item><item><title>KB: XML schema validation errors when Exchange Web Service requests and responses have invalid XML characters</title><link>http://blogs.msdn.com/mstehle/archive/2009/02/12/xml-schema-validation-errors-when-exchange-web-service-requests-and-responses-have-invalid-xml-characters.aspx</link><pubDate>Thu, 12 Feb 2009 23:23:21 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9416212</guid><dc:creator>mstehle</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/mstehle/comments/9416212.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mstehle/commentrss.aspx?PostID=9416212</wfw:commentRss><wfw:comment>http://blogs.msdn.com/mstehle/rsscomments.aspx?PostID=9416212</wfw:comment><description>&lt;p&gt;&lt;em&gt;…I recently submitted the following KB article for publication but wanted to get the content out.&amp;#160; I will update this post when the KB article is published…&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;SYMPTOMS&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;Scenario 1&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;When you submit an Exchange Web Services request to Microsoft Exchange Server 2007 that contains invalid XML characters, you may get the following &lt;i&gt;ErrorSchemaValidation&lt;/i&gt; exception response:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;i&gt;“The request failed schema validation: [character], hexadecimal value [value], is an invalid character.”&lt;/i&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;i&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p&gt;Scenario 2&lt;/p&gt;  &lt;p&gt;When you submit an Exchange Web Services request to Microsoft Exchange Server 2007 that returns item properties in the response containing invalid XML characters using the Visual Studio auto-generated proxy classes, you may get the following &lt;i&gt;InvalidOperationException &lt;/i&gt;exception:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;i&gt;”There is an error in XML document”&lt;/i&gt;&lt;/p&gt;    &lt;p&gt;&lt;i&gt;“[character] hexadecimal value [value], is an invalid character.”&lt;/i&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;CAUSE&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;It is possible for Exchange item properties to have values that contain characters outside the valid range in the XML specification which is defined here:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://www.w3.org/TR/2000/WD-xml-2e-20000814#dt-character"&gt;http://www.w3.org/TR/2000/WD-xml-2e-20000814#dt-character&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;When an Exchange Web Services client makes a request to retrieve that item property, the Exchange server encodes the property values to ensure the response is transmittable.&amp;#160; If this response is received by the client and subsequently validated against the XML schema, it will fail validation because of the invalid XML characters.&lt;/p&gt;  &lt;p&gt;Conversely, if an Exchange Web Services client tries to send these characters in a request, even if they are encoded, the Exchange server will try and validate the request against the XML schema which will fail.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;RESOLUTION&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;Scenario 1&lt;/p&gt;  &lt;p&gt;There is no way to successfully post an Exchange Web Service request that contains invalid XML characters.&amp;#160; If you are updating a property’s value that contains invalid characters you must decide whether to replace or omit these characters.&lt;/p&gt;  &lt;p&gt;Scenario 2&lt;/p&gt;  &lt;p&gt;In order to read Exchange Web Service responses from Microsoft Exchange Server 2007 that contain invalid XML characters, you should skip XML validation. If you are using the Visual Studio auto-generated proxy classes for Exchange Web Services then you can create a special partial class which overrides the GetReaderForMessage method of the ExchangeServiceBinding class which turns XML validation off:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;span style="color: blue"&gt;public partial class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;MyExchangeServiceBinding&lt;/span&gt;: &lt;span style="color: #2b91af"&gt;ExchangeServiceBinding        &lt;br /&gt;&lt;/span&gt;{       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;protected override&lt;/span&gt;&lt;span style="color: #2b91af"&gt;XmlReader &lt;/span&gt;GetReaderForMessage(       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #2b91af"&gt;SoapClientMessage &lt;/span&gt;message,       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;int &lt;/span&gt;bufferSize)       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #2b91af"&gt;XmlReader &lt;/span&gt;retval = &lt;span style="color: blue"&gt;base&lt;/span&gt;.GetReaderForMessage(       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; message,       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; bufferSize);       &lt;br /&gt;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: #2b91af"&gt;XmlTextReader &lt;/span&gt;xrt = retval &lt;span style="color: blue"&gt;as&lt;/span&gt;&lt;span style="color: #2b91af"&gt;XmlTextReader&lt;/span&gt;;       &lt;br /&gt;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;if&lt;/span&gt;(&lt;span style="color: blue"&gt;null&lt;/span&gt;!= xrt)       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; xrt.Normalization = &lt;span style="color: blue"&gt;false&lt;/span&gt;;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color: blue"&gt;return&lt;/span&gt;retval;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;}&lt;/p&gt;&lt;/blockquote&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9416212" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mstehle/archive/tags/KB/default.aspx">KB</category><category domain="http://blogs.msdn.com/mstehle/archive/tags/Exchange+Web+Services/default.aspx">Exchange Web Services</category><category domain="http://blogs.msdn.com/mstehle/archive/tags/DevMsgTeam/default.aspx">DevMsgTeam</category></item><item><title>FYI: Exchange 2007 OnSyncSave Store Events and Plain Text Message Don’t Play Nice</title><link>http://blogs.msdn.com/mstehle/archive/2009/02/05/fyi-exchange-2007-onsyncsave-store-events-and-plain-text-message-don-t-play-nice.aspx</link><pubDate>Thu, 05 Feb 2009 22:54:50 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9400081</guid><dc:creator>mstehle</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/mstehle/comments/9400081.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mstehle/commentrss.aspx?PostID=9400081</wfw:commentRss><wfw:comment>http://blogs.msdn.com/mstehle/rsscomments.aspx?PostID=9400081</wfw:comment><description>&lt;p&gt;&lt;em&gt;&lt;font size="2" face="Arial"&gt;…Recently, I worked with a customer who was facing the problem described below.&amp;#160; We requested a fix but ended up finding a &lt;/font&gt;&lt;a href="http://blogs.msdn.com/mstehle/archive/2009/01/13/howto-sample-transport-agent-add-headers-categories-mapi-props-even-uses-a-fork.aspx" target="_blank"&gt;&lt;font size="2" face="Arial"&gt;workaround&lt;/font&gt;&lt;/a&gt;&lt;font size="2" face="Arial"&gt; using a Transport Agent.&amp;#160; At this time there is no plan to fix this issue in Exchange 2007…&lt;/font&gt;&lt;/em&gt;&lt;/p&gt;  &lt;h2&gt;&lt;font size="2" face="Arial"&gt;Problem Description&lt;/font&gt;&lt;/h2&gt;  &lt;p&gt;&lt;font size="2" face="Arial"&gt;In an &lt;/font&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/aa562973.aspx" target="_blank"&gt;&lt;font size="2" face="Arial"&gt;OnSyncSave&lt;/font&gt;&lt;/a&gt;&lt;font size="2" face="Arial"&gt; store event in Exchange 2007 every field's value of a plain text message which triggers the event returns the following exception in the first pre-commit event:&lt;/font&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font size="2" face="Arial"&gt; &amp;quot;Operation failed to complete and the status is unavailable. The field may be unavailable or the operation was not attempted.&amp;quot; &lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;font size="2" face="Arial"&gt;When the &lt;/font&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/aa562973.aspx" target="_blank"&gt;&lt;font size="2" face="Arial"&gt;OnSyncSave&lt;/font&gt;&lt;/a&gt;&lt;font size="2" face="Arial"&gt; event fires again for this message after the message has been committed to the store the property values can be read.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;&lt;font size="2"&gt;&lt;font face="Arial"&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; HTML and RTF messages do not have this problem - this only applies to Plain Text messages.&lt;/font&gt;&lt;/font&gt;&lt;/em&gt;&lt;/p&gt;  &lt;h2&gt;&lt;font size="2" face="Arial"&gt;Workarounds&lt;/font&gt;&lt;/h2&gt;  &lt;p&gt;&lt;font size="2" face="Arial"&gt;There are no straight forward workarounds, only other options which may or may not suit your application’s needs:&lt;/font&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;font size="2" face="Arial"&gt;Use the &lt;/font&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/aa566475.aspx" target="_blank"&gt;&lt;font size="2" face="Arial"&gt;OnSave&lt;/font&gt;&lt;/a&gt;&lt;font size="2" face="Arial"&gt; asynchronous event sink.&amp;#160; The trade off here is obvious but the OnSave event doesn’t have any problem reading properties from a message that triggers the event.&lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;font size="2" face="Arial"&gt;Use a &lt;/font&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/aa579185.aspx" target="_blank"&gt;&lt;font size="2" face="Arial"&gt;Transport Agent&lt;/font&gt;&lt;/a&gt;&lt;font size="2" face="Arial"&gt;.&amp;#160; The main trade off here is that transport agents operate outside of the mailbox in the transport stack.&amp;#160; They can’t react to events that happen within a mailbox such as changing an item in the calendar or moving a message from one folder to another.&amp;#160; They only react to mail being delivered to or sent from a mailbox.&lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;font size="2" face="Arial"&gt;Use an &lt;/font&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/bb226710.aspx" target="_blank"&gt;&lt;font size="2" face="Arial"&gt;Outlook Add-in&lt;/font&gt;&lt;/a&gt;&lt;font size="2" face="Arial"&gt;.&amp;#160; The big trade-off here is that changes in OWA are not handled, you can only react to events that the user triggers in Outlook.&lt;/font&gt;&lt;/li&gt;    &lt;li&gt;&lt;font size="2" face="Arial"&gt;Use &lt;/font&gt;&lt;a href="http://office.microsoft.com/en-us/outlook/HA100968031033.aspx?pid=CH101032711033" target="_blank"&gt;&lt;font size="2" face="Arial"&gt;rules&lt;/font&gt;&lt;/a&gt;&lt;font size="2" face="Arial"&gt;.&amp;#160; The main drawback is that they have a fixed set of functions but they don’t require any code to be written or bits to be deployed.&lt;/font&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;font size="2" face="Arial"&gt;Again, depending on your solution one of these workarounds or combination of two might accomplish what you need.&amp;#160; An example of combining two of these options would be to use a transport agent to tag messages as they are sent to a particular mailbox and then use a rule to key off this tag and move those messages to a specific folder on deliver.&lt;/font&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9400081" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mstehle/archive/tags/FYI/default.aspx">FYI</category><category domain="http://blogs.msdn.com/mstehle/archive/tags/Exchange+Eventing/default.aspx">Exchange Eventing</category><category domain="http://blogs.msdn.com/mstehle/archive/tags/DevMsgTeam/default.aspx">DevMsgTeam</category></item><item><title>HOWTO: Sample Transport Agent – Add Headers, Categories, MAPI Props, Even Uses a Fork!</title><link>http://blogs.msdn.com/mstehle/archive/2009/01/13/howto-sample-transport-agent-add-headers-categories-mapi-props-even-uses-a-fork.aspx</link><pubDate>Tue, 13 Jan 2009 21:50:33 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9317264</guid><dc:creator>mstehle</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/mstehle/comments/9317264.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mstehle/commentrss.aspx?PostID=9317264</wfw:commentRss><wfw:comment>http://blogs.msdn.com/mstehle/rsscomments.aspx?PostID=9317264</wfw:comment><description>&lt;p&gt;&lt;span style="color: blue"&gt;&lt;font color="#000000" size="2" face="Arial"&gt;Welcome to my first in depth Exchange Transport Agent sample!&amp;#160; If you are not familiar with Exchange Transport Agents &lt;a href="http://msexchangeteam.com/archive/2006/12/04/431755.aspx"&gt;this&lt;/a&gt; blog post is a great place to start.&amp;#160; I created a sample Transport Agent for a customer a while ago that I recently added commenting to and cleaned up so it could serve as a general demo &lt;/font&gt;&lt;/span&gt;&lt;span style="color: blue"&gt;&lt;font color="#000000" size="2" face="Arial"&gt;suitable for this blog. The focus of this sample is to illustrate a several techniques but no necessarily serve as a template or best practice for writing transport agents in general.&amp;#160; The key techniques illustrated are:&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;&lt;span style="color: blue"&gt;&lt;font color="#000000" size="2" face="Arial"&gt;Forking a message in the “OnSubmittedMessage” event to process a messages individually for each recipient.&lt;/font&gt;&lt;/span&gt;&lt;/li&gt;    &lt;li&gt;&lt;span style="color: blue"&gt;&lt;font color="#000000" size="2" face="Arial"&gt;Adding a custom header to a message.&lt;/font&gt;&lt;/span&gt;&lt;/li&gt;    &lt;li&gt;&lt;span style="color: blue"&gt;&lt;font color="#000000" size="2" face="Arial"&gt;Adding a Keywords (also known as Category) header to a message&lt;/font&gt;&lt;/span&gt;&lt;/li&gt;    &lt;li&gt;&lt;span style="color: blue"&gt;&lt;font color="#000000" size="2" face="Arial"&gt;Adding a custom named property to a MAPI message&lt;/font&gt;&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&lt;span style="color: blue"&gt;&lt;font color="#000000" size="2" face="Arial"&gt;The comments in the code speak for themselves so I won’t walk through it all.&amp;#160; There are two very important notes regarding the Keyword header and adding MAPI properties that I want to emphasize though.&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color: blue"&gt;&lt;strong&gt;&lt;font color="#000000" size="2" face="Arial"&gt;The Keywords Header is Removed By Default&lt;/font&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color: blue"&gt;&lt;font color="#000000" size="2" face="Arial"&gt;If you are you trying to add the Keywords header in a transport agent or even just when sending MIME messages to Exchange 2007 keep in mind that this header is translated into Categories which are removed by default during content conversion.&amp;#160; If you really need this functionality though, you can turn this off using the Set-TransportConfig cmdlet and setting ClearCategories to $false.&amp;#160; Click &lt;a href="http://technet.microsoft.com/en-us/library/bb124151.aspx"&gt;here&lt;/a&gt; to read more.&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color: blue"&gt;&lt;strong&gt;&lt;font color="#000000" size="2" face="Arial"&gt;If You Don’t Get TNEF, You Don’t Have TNEF&lt;/font&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color: blue"&gt;&lt;font color="#000000" size="2" face="Arial"&gt;There is no API to convert MIME messages to TNEF within a transport agent.&amp;#160; The TNEF body part must be a full representation of the message being submitted to Exchange.&amp;#160; You can’t have a complex MIME message with a TNEF body part that simply adds a MAPI property or two.&amp;#160; Messages that are submitted from outside the organization will mostly like not have TNEF, there is no mechanism to create a representative TNEF body part for these messages and then append properties.&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color: blue"&gt;&lt;font color="#000000" size="2" face="Arial"&gt;One final note is that this sample logs information out to a text file on the system.&amp;#160; Keep in mind that transport agents run in the context of the Exchange Transport Service which is typically Network Service.&amp;#160; In this case, the Network Service account would need write permissions to whatever folder the log file is configured to write to.&amp;#160; &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style="color: blue"&gt;&lt;font color="#000000" size="2" face="Arial"&gt;Enjoy…&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;ol&gt;   &lt;p&gt;&lt;span style="color: blue"&gt;&lt;font color="#000000" size="2" face="Arial"&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;/ol&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;using &lt;/span&gt;System;
&lt;span style="color: blue"&gt;using &lt;/span&gt;System.Collections.Generic;
&lt;span style="color: blue"&gt;using &lt;/span&gt;System.Text;
&lt;span style="color: blue"&gt;using &lt;/span&gt;System.IO;
&lt;span style="color: blue"&gt;using &lt;/span&gt;Microsoft.Exchange.Data.Transport;
&lt;span style="color: blue"&gt;using &lt;/span&gt;Microsoft.Exchange.Data.Transport.Routing;
&lt;span style="color: blue"&gt;using &lt;/span&gt;Microsoft.Exchange.Data.Common;
&lt;span style="color: blue"&gt;using &lt;/span&gt;Microsoft.Exchange.Data.Mime;
&lt;span style="color: blue"&gt;using &lt;/span&gt;Microsoft.Exchange.Data.ContentTypes.Tnef;

&lt;span style="color: blue"&gt;namespace &lt;/span&gt;MyRoutingAgent
{

    &lt;span style="color: blue"&gt;public sealed class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;MyRoutingAgentFactory &lt;/span&gt;: &lt;span style="color: #2b91af"&gt;RoutingAgentFactory
    &lt;/span&gt;{
        &lt;span style="color: blue"&gt;public override &lt;/span&gt;&lt;span style="color: #2b91af"&gt;RoutingAgent &lt;/span&gt;CreateAgent(&lt;span style="color: #2b91af"&gt;SmtpServer &lt;/span&gt;server)
        {
            &lt;span style="color: blue"&gt;return new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;MyRoutingAgent&lt;/span&gt;();
        }
    }

    &lt;span style="color: blue"&gt;public class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;MyRoutingAgent &lt;/span&gt;: &lt;span style="color: #2b91af"&gt;RoutingAgent
    &lt;/span&gt;{
        &lt;span style="color: green"&gt;// Place this text in the subject to test the agent
        &lt;/span&gt;&lt;span style="color: blue"&gt;public const string &lt;/span&gt;TEST_TOKEN = &lt;span style="color: #a31515"&gt;&amp;quot;[TEST]&amp;quot;&lt;/span&gt;;
        &lt;span style="color: blue"&gt;public const string &lt;/span&gt;LOG_FILE_PATH = &lt;span style="color: #a31515"&gt;@&amp;quot;C:\Users\Administrator\Desktop\MyRoutingAgent\MyRoutingAgent.log&amp;quot;&lt;/span&gt;;

        &lt;span style="color: blue"&gt;public &lt;/span&gt;MyRoutingAgent()
        {
            &lt;span style="color: blue"&gt;this&lt;/span&gt;.OnRoutedMessage += &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;RoutedMessageEventHandler&lt;/span&gt;(MyRoutingAgent_OnRoutedMessage);
            &lt;span style="color: blue"&gt;this&lt;/span&gt;.OnSubmittedMessage += &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;SubmittedMessageEventHandler&lt;/span&gt;(MyRoutingAgent_OnSubmittedMessage);
            &lt;span style="color: blue"&gt;this&lt;/span&gt;.OnResolvedMessage += &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ResolvedMessageEventHandler&lt;/span&gt;(MyRoutingAgent_OnResolvedMessage);
        }

        &lt;span style="color: blue"&gt;void &lt;/span&gt;MyRoutingAgent_OnSubmittedMessage(&lt;span style="color: #2b91af"&gt;SubmittedMessageEventSource &lt;/span&gt;source, &lt;span style="color: #2b91af"&gt;QueuedMessageEventArgs &lt;/span&gt;e)
        {
            &lt;span style="color: green"&gt;// Don't process EVERY message...
            &lt;/span&gt;&lt;span style="color: blue"&gt;if &lt;/span&gt;(e.MailItem.Message.Subject.Contains(TEST_TOKEN))
            {
                &lt;span style="color: green"&gt;// If we have multiple recipients, fork the message to process each recipient seperately...
                &lt;/span&gt;&lt;span style="color: blue"&gt;if &lt;/span&gt;(e.MailItem.Recipients.Count &amp;gt; 1)
                {
                    LogMessage(&lt;span style="color: #a31515"&gt;&amp;quot;OnSubmittedMessage&amp;quot;&lt;/span&gt;, e.MailItem, &lt;span style="color: #a31515"&gt;&amp;quot;Forking message with &amp;quot; &lt;/span&gt;+ e.MailItem.Recipients.Count + &lt;span style="color: #a31515"&gt;&amp;quot; recipients.&amp;quot;&lt;/span&gt;);

                    &lt;span style="color: blue"&gt;int &lt;/span&gt;count = 0;
                    &lt;span style="color: blue"&gt;while &lt;/span&gt;(e.MailItem.Recipients.Count &amp;gt; 1)
                    {
                        &lt;span style="color: green"&gt;// Create an individual forked message for each recipient...
                        &lt;/span&gt;&lt;span style="color: #2b91af"&gt;EnvelopeRecipient &lt;/span&gt;recip = e.MailItem.Recipients[e.MailItem.Recipients.Count - 1];
                        &lt;span style="color: #2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;EnvelopeRecipient&lt;/span&gt;&amp;gt; recips = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color: #2b91af"&gt;EnvelopeRecipient&lt;/span&gt;&amp;gt;();
                        recips.Add(recip);
                        source.Fork(recips);
                        count++;
                    }

                    &lt;span style="color: green"&gt;// This should always be one.
                    &lt;/span&gt;LogMessage(&lt;span style="color: #a31515"&gt;&amp;quot;OnSubmittedMessage&amp;quot;&lt;/span&gt;, e.MailItem, &lt;span style="color: #a31515"&gt;&amp;quot;Forked &amp;quot; &lt;/span&gt;+ count + &lt;span style="color: #a31515"&gt;&amp;quot; messages.&amp;quot;&lt;/span&gt;);
                }
                &lt;span style="color: blue"&gt;else
                &lt;/span&gt;{
                    LogMessage(&lt;span style="color: #a31515"&gt;&amp;quot;OnSubmittedMessage&amp;quot;&lt;/span&gt;, e.MailItem, &lt;span style="color: #a31515"&gt;&amp;quot;Single recipient, no forking needed.&amp;quot;&lt;/span&gt;);
                }
            }
        }

        &lt;span style="color: blue"&gt;void &lt;/span&gt;MyRoutingAgent_OnResolvedMessage(&lt;span style="color: #2b91af"&gt;ResolvedMessageEventSource &lt;/span&gt;source, &lt;span style="color: #2b91af"&gt;QueuedMessageEventArgs &lt;/span&gt;e)
        {
            &lt;span style="color: green"&gt;// Don't process EVERY message...
            &lt;/span&gt;&lt;span style="color: blue"&gt;if &lt;/span&gt;(e.MailItem.Message.Subject.Contains(TEST_TOKEN))
            {
                &lt;span style="color: #2b91af"&gt;MimePart &lt;/span&gt;tnefPart = e.MailItem.Message.TnefPart;
                &lt;span style="color: blue"&gt;if &lt;/span&gt;(tnefPart != &lt;span style="color: blue"&gt;null&lt;/span&gt;)
                {
                    LogMessage(&lt;span style="color: #a31515"&gt;&amp;quot;OnResolvedMessage&amp;quot;&lt;/span&gt;, e.MailItem, &lt;span style="color: #a31515"&gt;&amp;quot;TNEF&amp;quot;&lt;/span&gt;);
                }
                &lt;span style="color: blue"&gt;else
                &lt;/span&gt;{
                    LogMessage(&lt;span style="color: #a31515"&gt;&amp;quot;OnResolvedMessage&amp;quot;&lt;/span&gt;, e.MailItem, &lt;span style="color: #a31515"&gt;&amp;quot;No TNEF&amp;quot;&lt;/span&gt;);
                }
            }
        }
        
        &lt;span style="color: blue"&gt;void &lt;/span&gt;MyRoutingAgent_OnRoutedMessage(&lt;span style="color: #2b91af"&gt;RoutedMessageEventSource &lt;/span&gt;source, &lt;span style="color: #2b91af"&gt;QueuedMessageEventArgs &lt;/span&gt;e)
        {
            &lt;span style="color: green"&gt;// Don't process EVERY message...
            &lt;/span&gt;&lt;span style="color: blue"&gt;if &lt;/span&gt;(e.MailItem.Message.Subject.Contains(TEST_TOKEN))
            {
                &lt;span style="color: blue"&gt;if &lt;/span&gt;(e.MailItem.Recipients.Count == 1)
                {
                    LogMessage(&lt;span style="color: #a31515"&gt;&amp;quot;OnRoutedMessage&amp;quot;&lt;/span&gt;, e.MailItem, &lt;span style="color: #a31515"&gt;&amp;quot;Processing message sent to &amp;quot; &lt;/span&gt;+ e.MailItem.Recipients[0].Address.LocalPart + &lt;span style="color: #a31515"&gt;&amp;quot;.&amp;quot;&lt;/span&gt;);

                    &lt;span style="color: green"&gt;// If we haven't already processed this message...
                    &lt;/span&gt;&lt;span style="color: blue"&gt;if &lt;/span&gt;(e.MailItem.Message.MimeDocument.RootPart.Headers.FindFirst(&lt;span style="color: #a31515"&gt;&amp;quot;MyHeader&amp;quot;&lt;/span&gt;) == &lt;span style="color: blue"&gt;null&lt;/span&gt;)
                    {
                        ProcessMailItem(e.MailItem);
                    }
                    &lt;span style="color: blue"&gt;else
                    &lt;/span&gt;{
                        LogMessage(&lt;span style="color: #a31515"&gt;&amp;quot;OnRoutedMessage&amp;quot;&lt;/span&gt;, e.MailItem, &lt;span style="color: #a31515"&gt;&amp;quot;Already processed this message, skipping.&amp;quot;&lt;/span&gt;);
                    }
                }
                &lt;span style="color: blue"&gt;else
                &lt;/span&gt;{
                    LogMessage(&lt;span style="color: #a31515"&gt;&amp;quot;OnRoutedMessage&amp;quot;&lt;/span&gt;, e.MailItem, &lt;span style="color: #a31515"&gt;&amp;quot;Unexpected number of recipients, &amp;quot; &lt;/span&gt;+ e.MailItem.Recipients.Count.ToString() + &lt;span style="color: #a31515"&gt;&amp;quot;.&amp;quot;&lt;/span&gt;);
                }
            }
        }

        &lt;span style="color: gray"&gt;/// &amp;lt;summary&amp;gt;
        /// &lt;/span&gt;&lt;span style="color: green"&gt;Add a custom header, keyword header, and MAPI
        &lt;/span&gt;&lt;span style="color: gray"&gt;/// &lt;/span&gt;&lt;span style="color: green"&gt;named property into PS_PUBLIC_STRINGS if there
        &lt;/span&gt;&lt;span style="color: gray"&gt;/// &lt;/span&gt;&lt;span style="color: green"&gt;is a TNEF body part.
        &lt;/span&gt;&lt;span style="color: gray"&gt;/// &amp;lt;/summary&amp;gt;
        &lt;/span&gt;&lt;span style="color: blue"&gt;private void &lt;/span&gt;ProcessMailItem(&lt;span style="color: #2b91af"&gt;MailItem &lt;/span&gt;item)
        {
            &lt;span style="color: green"&gt;// Modify the subject of this message to ensure the
            // fork worked.  Append the first recipient name to the 
            // subject.  This should match the mailbox name the
            // message is delivered to.
            &lt;/span&gt;item.Message.Subject = item.Message.Subject + &lt;span style="color: #a31515"&gt;&amp;quot;| To: &amp;quot; &lt;/span&gt;+ item.Recipients[0].Address.LocalPart;

            &lt;span style="color: #2b91af"&gt;MimeDocument &lt;/span&gt;mdMimeDoc = item.Message.MimeDocument;
            &lt;span style="color: #2b91af"&gt;HeaderList &lt;/span&gt;hlHeaderlist = mdMimeDoc.RootPart.Headers;
            &lt;span style="color: #2b91af"&gt;MimeNode &lt;/span&gt;lhLasterHeader = hlHeaderlist.LastChild;

            &lt;span style="color: green"&gt;// Add a custom header
            &lt;/span&gt;&lt;span style="color: #2b91af"&gt;TextHeader &lt;/span&gt;nhNewHeader = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;TextHeader&lt;/span&gt;(&lt;span style="color: #a31515"&gt;&amp;quot;MyHeader&amp;quot;&lt;/span&gt;, &lt;span style="color: #a31515"&gt;&amp;quot;MyHeaderValue&amp;quot;&lt;/span&gt;);
            hlHeaderlist.InsertBefore(nhNewHeader, lhLasterHeader);

            &lt;span style="color: green"&gt;// Add the Keywords header to set a Category in Outlook/OWA.
            // *** INFO ***
            // Keywords (also known as Categories) are stripped from
            // message by default.  This can be disabled using the 
            // &amp;quot;Set-TransportConfig –ClearCategories $false&amp;quot; cmdlet.
            // (http://technet.microsoft.com/en-us/library/bb124151.aspx)
            &lt;/span&gt;&lt;span style="color: #2b91af"&gt;TextHeader &lt;/span&gt;nhNewKeywords = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;TextHeader&lt;/span&gt;(&lt;span style="color: #a31515"&gt;&amp;quot;Keywords&amp;quot;&lt;/span&gt;, &lt;span style="color: #a31515"&gt;&amp;quot;1&amp;quot;&lt;/span&gt;);
            hlHeaderlist.InsertBefore(nhNewKeywords, lhLasterHeader);

            &lt;span style="color: #2b91af"&gt;MimePart &lt;/span&gt;tnefPart = item.Message.TnefPart;

            &lt;span style="color: green"&gt;// Without a TNEF body part, we can't do this step.
            // There is no way to create a TNEF body part from
            // scratch if Exchange isn't giving us one.  Most
            // mail that comes from the internet won't have TNEF.
            &lt;/span&gt;&lt;span style="color: blue"&gt;if &lt;/span&gt;(tnefPart != &lt;span style="color: blue"&gt;null&lt;/span&gt;)
            {
                &lt;span style="color: #2b91af"&gt;TnefReader &lt;/span&gt;reader = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;TnefReader&lt;/span&gt;(tnefPart.GetContentReadStream());
                &lt;span style="color: #2b91af"&gt;TnefWriter &lt;/span&gt;writer = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;TnefWriter&lt;/span&gt;(
                    tnefPart.GetContentWriteStream(tnefPart.ContentTransferEncoding),
                    reader.AttachmentKey,
                    0,
                    &lt;span style="color: #2b91af"&gt;TnefWriterFlags&lt;/span&gt;.NoStandardAttributes);

                &lt;span style="color: blue"&gt;while &lt;/span&gt;(reader.ReadNextAttribute())
                {
                    &lt;span style="color: blue"&gt;if &lt;/span&gt;(reader.AttributeTag == &lt;span style="color: #2b91af"&gt;TnefAttributeTag&lt;/span&gt;.MapiProperties)
                    {
                        writer.StartAttribute(&lt;span style="color: #2b91af"&gt;TnefAttributeTag&lt;/span&gt;.MapiProperties, &lt;span style="color: #2b91af"&gt;TnefAttributeLevel&lt;/span&gt;.Message);
                        writer.WriteAllProperties(reader.PropertyReader);

                        &lt;span style="color: blue"&gt;int &lt;/span&gt;tag;
                        &lt;span style="color: blue"&gt;unchecked
                        &lt;/span&gt;{
                            &lt;span style="color: green"&gt;// The first four bytes of the tag is must be at least 0x8000 
                            // when setting a named property, the second determines the type. 
                            // http://www.cdolive.com/cdo10.htm
                            &lt;/span&gt;tag = (&lt;span style="color: blue"&gt;int&lt;/span&gt;)0x8000001E;
                        }

                        &lt;span style="color: #2b91af"&gt;Guid &lt;/span&gt;PS_PUBLIC_STRINGS = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Guid&lt;/span&gt;(&lt;span style="color: #a31515"&gt;&amp;quot;00020329-0000-0000-C000-000000000046&amp;quot;&lt;/span&gt;);

                        writer.StartProperty(
                            &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;TnefPropertyTag&lt;/span&gt;(tag),
                            PS_PUBLIC_STRINGS,
                            &lt;span style="color: #a31515"&gt;&amp;quot;MyProp&amp;quot;&lt;/span&gt;);
                        writer.WritePropertyValue(&lt;span style="color: #a31515"&gt;&amp;quot;Hello!&amp;quot;&lt;/span&gt;);
                    }
                    &lt;span style="color: blue"&gt;else
                    &lt;/span&gt;{
                        writer.WriteAttribute(reader);
                    }
                }

                &lt;span style="color: green"&gt;//  Close writer
                &lt;/span&gt;&lt;span style="color: blue"&gt;if &lt;/span&gt;(&lt;span style="color: blue"&gt;null &lt;/span&gt;!= writer)
                {
                    writer.Close();
                }

                LogMessage(&lt;span style="color: #a31515"&gt;&amp;quot;ProcessMailItem&amp;quot;&lt;/span&gt;, item, &lt;span style="color: #a31515"&gt;&amp;quot;Added 'MyProp' to PS_PUBLIC_STRINGS.&amp;quot;&lt;/span&gt;);
            }
            &lt;span style="color: blue"&gt;else
            &lt;/span&gt;{
                LogMessage(&lt;span style="color: #a31515"&gt;&amp;quot;ProcessMailItem&amp;quot;&lt;/span&gt;, item, &lt;span style="color: #a31515"&gt;&amp;quot;No TNEF, not adding property&amp;quot;&lt;/span&gt;);
            }
        }

        &lt;span style="color: blue"&gt;private void &lt;/span&gt;LogMessage(&lt;span style="color: blue"&gt;string &lt;/span&gt;eventName, &lt;span style="color: #2b91af"&gt;MailItem &lt;/span&gt;item, &lt;span style="color: blue"&gt;string &lt;/span&gt;message)
        {
            &lt;span style="color: #2b91af"&gt;TextWriter &lt;/span&gt;tw = System.IO.&lt;span style="color: #2b91af"&gt;File&lt;/span&gt;.AppendText(LOG_FILE_PATH);
            tw.WriteLine(&lt;span style="color: #2b91af"&gt;DateTime&lt;/span&gt;.Now.Ticks + &lt;span style="color: #a31515"&gt;&amp;quot;\t&amp;quot; &lt;/span&gt;+ eventName + &lt;span style="color: #a31515"&gt;&amp;quot; - &amp;quot; &lt;/span&gt;+ item.Message.Subject + &lt;span style="color: #a31515"&gt;&amp;quot; - &amp;quot; &lt;/span&gt;+ message);
            tw.Close();
        }
    }

}&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9317264" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mstehle/archive/tags/HOWTO/default.aspx">HOWTO</category><category domain="http://blogs.msdn.com/mstehle/archive/tags/Exchange+Eventing/default.aspx">Exchange Eventing</category><category domain="http://blogs.msdn.com/mstehle/archive/tags/DevMsgTeam/default.aspx">DevMsgTeam</category><category domain="http://blogs.msdn.com/mstehle/archive/tags/Transport+Agents/default.aspx">Transport Agents</category></item><item><title>Jason Henderson: A Brief History and Exciting Future for Exchange Development</title><link>http://blogs.msdn.com/mstehle/archive/2008/12/12/jason-henderson-a-brief-history-and-exciting-future-for-exchange-development.aspx</link><pubDate>Fri, 12 Dec 2008 15:42:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9202523</guid><dc:creator>mstehle</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/mstehle/comments/9202523.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mstehle/commentrss.aspx?PostID=9202523</wfw:commentRss><wfw:comment>http://blogs.msdn.com/mstehle/rsscomments.aspx?PostID=9202523</wfw:comment><description>&lt;P&gt;&lt;FONT size=2 face=Arial&gt;It took me forever to get around to watching this but this is just a great presentation about Exchange development’s future at PDC.&amp;nbsp; He does a great job of explaining where we’ve been as well…&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/exchangedev/archive/2008/10/15/learn-about-the-exchange-web-services-managed-api-and-how-exchange-is-getting-cloud-ready-at-pdc-08.aspx" target=_blank mce_href="http://blogs.msdn.com/exchangedev/archive/2008/10/15/learn-about-the-exchange-web-services-managed-api-and-how-exchange-is-getting-cloud-ready-at-pdc-08.aspx"&gt;&lt;FONT size=2 face=Arial&gt;Learn about the Exchange Web Services Managed API and how Exchange is getting “Cloud Ready” at PDC’08&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2 face=Arial&gt;This is an absolute must watch for any Exchange developer!&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9202523" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mstehle/archive/tags/Exchange+General/default.aspx">Exchange General</category><category domain="http://blogs.msdn.com/mstehle/archive/tags/Exchange+Web+Services/default.aspx">Exchange Web Services</category><category domain="http://blogs.msdn.com/mstehle/archive/tags/DevMsgTeam/default.aspx">DevMsgTeam</category><category domain="http://blogs.msdn.com/mstehle/archive/tags/Exchange+Web+Services+Managed+API/default.aspx">Exchange Web Services Managed API</category></item><item><title>FYI: The MAPI docs have moved...</title><link>http://blogs.msdn.com/mstehle/archive/2008/12/04/fyi-the-mapi-docs-have-moved.aspx</link><pubDate>Thu, 04 Dec 2008 21:46:44 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9177046</guid><dc:creator>mstehle</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/mstehle/comments/9177046.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mstehle/commentrss.aspx?PostID=9177046</wfw:commentRss><wfw:comment>http://blogs.msdn.com/mstehle/rsscomments.aspx?PostID=9177046</wfw:comment><description>&lt;p&gt;&lt;font size="2" face="Arial"&gt;The MAPI docs have been revamped and moved from Exchange to &lt;a href="http://msdn.microsoft.com/en-us/library/cc765775.aspx"&gt;Outlook 2007&lt;/a&gt; in MSDN.&amp;#160; As &lt;a href="http://blogs.msdn.com/exchangedev/archive/2008/12/04/mapi-documentation-moved-to-office.aspx"&gt;Thom points out&lt;/a&gt; - they did great work on these updated docs.&amp;#160; Steve also has a &lt;a href="http://blogs.msdn.com/stephen_griffin/archive/2008/12/02/welcome-to-the-outlook-2007-mapi-reference.aspx"&gt;post&lt;/a&gt; about this along with an overview.&amp;#160; If you are interested in MAPI, go check them out!&lt;/font&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9177046" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mstehle/archive/tags/MAPI/default.aspx">MAPI</category><category domain="http://blogs.msdn.com/mstehle/archive/tags/DevMsgTeam/default.aspx">DevMsgTeam</category></item></channel></rss>