<?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>Wiz/dumb : MAPI</title><link>http://blogs.msdn.com/pcreehan/archive/tags/MAPI/default.aspx</link><description>Tags: MAPI</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>ConfigureMsgService fails with MAPI_E_INVALID_PARAMETER (0x80070057)</title><link>http://blogs.msdn.com/pcreehan/archive/2009/07/10/configuremsgservice-fails-with-mapi-e-invalid-parameter-0x80070057.aspx</link><pubDate>Fri, 10 Jul 2009 16:02:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9824944</guid><dc:creator>Patrick Creehan</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/pcreehan/comments/9824944.aspx</comments><wfw:commentRss>http://blogs.msdn.com/pcreehan/commentrss.aspx?PostID=9824944</wfw:commentRss><description>&lt;p&gt;I recently helped a customer with an issue where they were calling &lt;a href="http://msdn.microsoft.com/en-us/library/cc815632.aspx" target="_blank"&gt;ConfigureMsgService&lt;/a&gt; and that call was failing, returning an HRESULT of MAPI_E_INVALID_PARAMETER (0x80070057). After debugging it, we established that the reason that ConfigureMsgService was failing was that the PR_PROFILE_HOME_SERVER_ADDRS property was missing from the profile. Outlook seemed to work fine, logons worked, sending mail worked; it was just that ConfigureMsgService would fail. We tried recreating the profile, but still the property wasn’t being set on the profile.&lt;/p&gt;  &lt;p&gt;It turns out that PR_PROFILE_HOME_SERVER_ADDRS gets its value from PR_EMS_AB_NETWORK_ADDRESS, which in turn, gets its value from the networkAddress attribute on the server object in Active Directory. That value was set correctly, but permissions to that object were not. After following the requirements laid out on &lt;a href="http://technet.microsoft.com/en-us/library/bb123738(EXCHG.65).aspx" target="_blank"&gt;technet&lt;/a&gt; for permissions to AD objects, we determined that the Authenticated Users group was missing the ACL for Read All Properties on the server object. Once we set that permission and recreated the profile, the property was set correctly on the profile and ConfigureMsgService started succeeding.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9824944" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/pcreehan/archive/tags/Outlook/default.aspx">Outlook</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/Exchange/default.aspx">Exchange</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/MAPI/default.aspx">MAPI</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/Outlook+2007/default.aspx">Outlook 2007</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/Exchange+2007/default.aspx">Exchange 2007</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/DevMsgTeam/default.aspx">DevMsgTeam</category></item><item><title>TNEF (Chapter 2): Old School</title><link>http://blogs.msdn.com/pcreehan/archive/2009/01/27/tnef-chapter-2-old-school.aspx</link><pubDate>Wed, 28 Jan 2009 02:09:40 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9378932</guid><dc:creator>Patrick Creehan</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/pcreehan/comments/9378932.aspx</comments><wfw:commentRss>http://blogs.msdn.com/pcreehan/commentrss.aspx?PostID=9378932</wfw:commentRss><description>&lt;p&gt;As discussed in &lt;a href="http://blogs.msdn.com/pcreehan/archive/2009/01/16/tnef-chapter-1-basics.aspx" target="_blank"&gt;Chapter 1&lt;/a&gt; of this captivating series, MAPI contains an interface to allow developers to create and read TNEF data. This interface is the &lt;a href="http://msdn.microsoft.com/en-us/library/cc840016.aspx" target="_blank"&gt;ITnef&lt;/a&gt; interface. There are only a few methods in this interface and they are, for the most part, self explanatory. The entire process of creating a TNEF stream can be done in just a few steps: &lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Call &lt;a href="http://msdn.microsoft.com/en-us/library/cc839976.aspx" target="_blank"&gt;OpenTnefStreamEx&lt;/a&gt; to get a TNEF stream to write into.       &lt;br /&gt;      &lt;br /&gt;Make sure you pass in TNEF_ENCODE since you’ll be creating TNEF. If you were reading TNEF, you’d pass in TNEF_DECODE instead. The other flags to worry about here are TNEF_BEST_DATA, TNEF_COMPATIBILITY, and TNEF_PURE. All of these just signal to MAPI how you want the properties you add to the TNEF stream treated. They will either be all converted to the old-school attributes (TNEF_COMPATIBILITY) – you shouldn’t use this one; some will be converted to attributes but also written to the attMAPIProps section (TNEF_BEST_DATA); or they will all just be written to the MAPI props and none of them written to the attributes (TNEF_PURE). &lt;/li&gt;    &lt;li&gt;Call &lt;a href="http://msdn.microsoft.com/en-us/library/cc815786.aspx" target="_blank"&gt;EncodeRecips&lt;/a&gt; and pass in the Recipient table you get from a call to &lt;a href="http://msdn.microsoft.com/en-us/library/cc815662.aspx"&gt;IMessage::GetRecipientTable&lt;/a&gt; on your message. &lt;/li&gt;    &lt;li&gt;Call &lt;a href="http://msdn.microsoft.com/en-us/library/cc839951.aspx" target="_blank"&gt;AddProps&lt;/a&gt; passing in an &lt;a href="http://msdn.microsoft.com/en-us/library/cc765903.aspx" target="_blank"&gt;SPropTagArray&lt;/a&gt; of non-transmittable prop tags and use the TNEF_PROP_EXCLUDE flag.       &lt;br /&gt;      &lt;br /&gt;There are essentially two schools of thought for building your TNEF: exclude the props you don’t want and let MAPI deal with the rest; or choose carefully which props you &lt;em&gt;do&lt;/em&gt; want to include and add them each piecemeal. These are the reason for having the TNEF_PROP_EXCLUDE and TNEF_PROP_INCLUDE flags. One of them says here are the properties I don’t want you to encode (TNEF_PROP_EXCLUDE) and the other, TNEF_PROP_INCLUDE, says I want you to include all of these properties.       &lt;br /&gt;      &lt;br /&gt;There’s another method, &lt;a title="ITnef--SetProps" href="http://msdn.microsoft.com/en-us/library/cc765611.aspx"&gt;SetProps&lt;/a&gt;, which does just that, sets the value of a property in the TNEF stream to a value you supply. This allows you to modify the data of the message you are trying to encode, or add additional properties that weren’t on the original.       &lt;br /&gt;      &lt;br /&gt;Back to &lt;a href="http://msdn.microsoft.com/en-us/library/cc839951.aspx" target="_blank"&gt;AddProps&lt;/a&gt; for a moment. The flags that supports don’t stop with TNEF_PROP_INCLUDE and TNEF_PROP_EXCLUDE, There is also TNEF_PROP_ATTACHMENTS_ONLY which says “of the properties I’ve given you to work with, I only want you to include/exclude the ones that have to do with attachments. Contrast that with TNEF_PROP_MESSAGE_ONLY which says &amp;quot;”of the properties I’ve given you to work with, I only want you to include/exclude the ones that have to do with the message itself – not attachments.” Then there’s the CONTAINED flags: TNEF_PROP_CONTAINED and TNEF_PROP_CONTAINED_TNEF. TNEF_PROP_CONTAINED means that these properties are going on an attachment; and the TNEF_PROP_CONTAINED_TNEF means I have TNEF data I’m going to give you to put in an attachment – like if you already had a TNEF blob you wanted to include as an attachment, which I’ll demonstrate below. &lt;/li&gt;    &lt;li&gt;Once you get all your properties added and included/excluded properly, you call &lt;a href="http://msdn.microsoft.com/en-us/library/cc765543.aspx"&gt;Finish&lt;/a&gt; and you’re done. One thing that makes it a little complicated though, is that you have to keep alive all the pointers and streams, etc you’re using in your TNEF until Finish is called, because that’s when all the internal work is actually done. So when you call Finish, that’s when MAPI says, Oh, ok, let me go get that recipient table you gave me. If you’ve already released it, then the process fails. &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;So it’s pretty easy to do this. This is essentially the way that &lt;a href="http://www.codeplex.com/mfcmapi"&gt;MFCMAPI&lt;/a&gt; demonstrates how to do it (look in File.cpp under SaveToTNEF). There are problems associated with doing it this way when it comes to Unicode properties and when having multiple embedded messages.&lt;/p&gt;  &lt;p&gt;The more complicated way to do this to work around some of the issues described above is to add the properties you want explicitly, including each attachment. &lt;/p&gt;  &lt;p&gt;The basic difference in the strategy is that instead of calling &lt;a href="http://msdn.microsoft.com/en-us/library/cc839951.aspx" target="_blank"&gt;AddProps&lt;/a&gt; with TNEF_PROP_EXCLUDE, call it with TNEF_PROP_INCLUDE and give it the &lt;a href="http://msdn.microsoft.com/en-us/library/cc765903.aspx" target="_blank"&gt;SPropTagArray&lt;/a&gt; you get from a call to &lt;a href="http://msdn.microsoft.com/en-us/library/cc765530.aspx"&gt;GetPropList&lt;/a&gt; on the message. You’ll need to filter out the non-transmittable properties (such as custom props and things like the Store EntryID). Once you add all the message props, call &lt;a href="http://msdn.microsoft.com/en-us/library/cc839924.aspx"&gt;GetAttachmentTable&lt;/a&gt; and loop through each attachment and do one of two things, if it’s not an embedded message, just add the attachment data with &lt;a href="http://msdn.microsoft.com/en-us/library/cc839951.aspx" target="_blank"&gt;AddProps&lt;/a&gt; on PR_ATTACH_DATA_BIN; otherwise, you’re going to recurse over yourself and build a TNEF stream from the embedded message. When you call Finish on it, then you’ll add it to the parent TNEF stream by calling &lt;a href="http://msdn.microsoft.com/en-us/library/cc839951.aspx" target="_blank"&gt;AddProps&lt;/a&gt; with PR_ATTACH_DATA_OBJ and using the TNEF_PROP_CONTAINED_TNEF flag and give it the stream for your TNEF blob. Once you unwind all the way, you’ll have your “master” TNEF stream. Essentially, you’ll follow the steps here: &lt;a title="http://msdn.microsoft.com/en-us/library/cc839833.aspx" href="http://msdn.microsoft.com/en-us/library/cc839833.aspx"&gt;http://msdn.microsoft.com/en-us/library/cc839833.aspx&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9378932" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/pcreehan/archive/tags/Outlook/default.aspx">Outlook</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/Exchange/default.aspx">Exchange</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/MAPI/default.aspx">MAPI</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/DevMsgTeam/default.aspx">DevMsgTeam</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/TNEF/default.aspx">TNEF</category></item><item><title>TNEF (Chapter 1): Basics</title><link>http://blogs.msdn.com/pcreehan/archive/2009/01/16/tnef-chapter-1-basics.aspx</link><pubDate>Fri, 16 Jan 2009 19:17:36 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9329079</guid><dc:creator>Patrick Creehan</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/pcreehan/comments/9329079.aspx</comments><wfw:commentRss>http://blogs.msdn.com/pcreehan/commentrss.aspx?PostID=9329079</wfw:commentRss><description>&lt;p&gt;I’ve worked quite a few cases recently regarding problems some folks have had either reading or composing TNEF content. I’ve learned quite a bit myself as a result, and I thought I’d share. I decided I would do a series of blog posts on the topic and hopefully save some of you the time I spent learning all this.&lt;/p&gt;  &lt;p&gt;So, being the first post on the topic, I suppose now would be a good time for a review on just what TNEF is and how it’s structured.&lt;/p&gt;  &lt;p&gt;TNEF stands for Transport-Neutral Encapsulation Format. If you use Outlook or any other MAPI client as your mail client, you may know that MAPI is a protocol for communication between the client and the mailbox server. MAPI defines a set of interfaces which the client can use to work with the data in the mailbox. The MAPI structure for the data is hierarchical with messages being contained in containers, which themselves can have a parent container, all the way up to the root of the store. MAPI also defines a set of properties understood by the client and, in some cases, the server. If all mail sent could stay on this one server and only go between clients on this one system, this would be all we need; but we know that’s not the case. A very large quantity of e-mail is sent over the internet to foreign systems every day. The vast majority of those use an industry-standard protocol called SMTP (Simple Mail Transfer Protocol) to send messages in an industry-standard format called MIME (Multipurpose Internet Mail Extensions). MIME is composed of body parts, which can in turn be composed of additional body parts themselves. MIME also allows you to add headers to each of the body parts which allow you to describe the content of that body part. So one body part may be a Word Document attachment, so the MIME headers on that body part would contain the MIME type such as application/doc and the transfer type, such as base64. The content of that body part would then contain a base64 encoding of the document. The headers for the root body part contain information such as the subject of the message, the sender and recipient information, etc. &lt;/p&gt;  &lt;p&gt;As a message makes its way through transport from one person’s email client to another person’s, it encounters many “hops” (brief stops at SMTP servers in the routing path) which have the opportunity to modify the headers. They do this in order to track the path the message took or to flag it as SPAM, verify the sender address, etc. So there’s a chance the headers you specify when you send the message won’t be the same as when the message arrives at the destination. The headers also only support text values. One of the problems discovered early on about the MIME format was that it has no concept of “rich text.” &lt;/p&gt;  &lt;p&gt;In early versions of Outlook, users wanted the ability to send and receive email that contained rich text bodies. Microsoft devised a plan to create an attachment to the messages it was sending that would have a certain content-type and would come to have a well-known name, “winmail.dat”. This attachment would contain an &lt;em&gt;encapsulation&lt;/em&gt; of the MAPI properties that could represent this rich body that would work across any transport and be readable by any system that supported MIME.&lt;/p&gt;  &lt;p&gt;The original structure just supported a very simple structure that was basically Name/size/value. These were called “attributes” and the names of these attributes are still prefixed by “att.” Many of the attribute names can be seen here: &lt;a title="http://msdn.microsoft.com/en-us/library/cc765736.aspx" href="http://msdn.microsoft.com/en-us/library/cc765736.aspx"&gt;http://msdn.microsoft.com/en-us/library/cc765736.aspx&lt;/a&gt;. The most important of these attributes for the purposes of our discussion will be the &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/cc842114.aspx"&gt;attMAPIProps&lt;/a&gt;. This attribute contains a list of MAPI properties that the receiving system can set on the message once it has converted the other MIME parts into their MAPI format. Some of the TNEF attributes can be directly translated into MAPI properties as defined by the link earlier in this paragraph, but there is not a 1-1 mapping between TNEF attributes and MAPI properties – hence the attMAPIProps attribute. Attachments and recipient data can also be encoded into the TNEF structure, which we’ll examine more later.&lt;/p&gt;  &lt;p&gt;MSDN documents the general structure of TNEF but it’s hard to understand. Last year, when Exchange decided to be among those systems that elected to publicly document their protocols, they created &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/cc425498.aspx"&gt;[MS-OXTNEF].pdf&lt;/a&gt;, which documents very clearly the structure of the TNEF data and how to parse it. Don’t get too nervous, though. I have parsed a 3MB TNEF blob manually myself, but in Exchange 2007, we provide &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/microsoft.exchange.data.contenttypes.tnef.aspx"&gt;managed code interfaces&lt;/a&gt; to allow you to read (or write) this data very easily. In subsequent posts, I’ll dive more into the structure and into the managed classes, as well as the legacy &lt;a target="_blank" href="http://msdn.microsoft.com/en-us/library/cc840016.aspx"&gt;MAPI ITnef&lt;/a&gt; interfaces, and more into problems you may experience in developing TNEF-enabled applications.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9329079" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/pcreehan/archive/tags/Outlook/default.aspx">Outlook</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/Exchange/default.aspx">Exchange</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/MAPI/default.aspx">MAPI</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/MIME/default.aspx">MIME</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/DevMsgTeam/default.aspx">DevMsgTeam</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/TNEF/default.aspx">TNEF</category></item><item><title>New Drop of MAPI/CDO Download Released Today</title><link>http://blogs.msdn.com/pcreehan/archive/2008/12/19/new-drop-of-mapi-cdo-download-released-today.aspx</link><pubDate>Sat, 20 Dec 2008 00:48:47 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9242911</guid><dc:creator>Patrick Creehan</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/pcreehan/comments/9242911.aspx</comments><wfw:commentRss>http://blogs.msdn.com/pcreehan/commentrss.aspx?PostID=9242911</wfw:commentRss><description>&lt;p&gt;After a hiccup earlier this week in getting the new MAPI &amp;amp; CDO downloads published to microsoft.com, they released today.&lt;/p&gt;  &lt;p&gt;MAPI / CDO&lt;/p&gt;  &lt;p&gt;&lt;a title="http://www.microsoft.com/downloads/details.aspx?familyid=E17E7F31-079A-43A9-BFF2-0A110307611E&amp;amp;displaylang=en" href="http://www.microsoft.com/downloads/details.aspx?familyid=E17E7F31-079A-43A9-BFF2-0A110307611E&amp;amp;displaylang=en"&gt;http://www.microsoft.com/downloads/details.aspx?familyid=E17E7F31-079A-43A9-BFF2-0A110307611E&amp;amp;displaylang=en&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;CDO 1.21&lt;/p&gt;  &lt;p&gt;&lt;a title="http://www.microsoft.com/downloads/details.aspx?familyid=2714320D-C997-4DE1-986F-24F081725D36&amp;amp;displaylang=en" href="http://www.microsoft.com/downloads/details.aspx?familyid=2714320D-C997-4DE1-986F-24F081725D36&amp;amp;displaylang=en"&gt;http://www.microsoft.com/downloads/details.aspx?familyid=2714320D-C997-4DE1-986F-24F081725D36&amp;amp;displaylang=en&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9242911" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/pcreehan/archive/tags/MAPI/default.aspx">MAPI</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/CDO+1.21/default.aspx">CDO 1.21</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/DevMsgTeam/default.aspx">DevMsgTeam</category></item><item><title>MAPI Docs Moved</title><link>http://blogs.msdn.com/pcreehan/archive/2008/12/04/mapi-docs-moved.aspx</link><pubDate>Thu, 04 Dec 2008 18:34:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9175526</guid><dc:creator>Patrick Creehan</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/pcreehan/comments/9175526.aspx</comments><wfw:commentRss>http://blogs.msdn.com/pcreehan/commentrss.aspx?PostID=9175526</wfw:commentRss><description>&lt;P&gt;So, the Exchange team decided they didn't want to maintain the MAPI documentation anymore since they don't ship MAPI anymore. So the Outlook team stepped up and took over the docs. As such, you can now find them under the Outlook branch in the MSDN left-nav.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/cc765775.aspx"&gt;http://msdn.microsoft.com/en-us/library/cc765775.aspx&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A target=_blank href="http://blogs.msdn.com/stephen_griffin" mce_href="http://blogs.msdn.com/stephen_griffin"&gt;Steve Griffin&lt;/A&gt; has been working with the Outlook team&amp;nbsp;on prettying them up and updating them for a few months,&amp;nbsp;and they're now&amp;nbsp;better than ever! He even got a new icon for &lt;A target=_blank href="http://www.codeplex.com/mfcmapi" mce_href="http://www.codeplex.com/mfcmapi"&gt;MFCMAPI&lt;/A&gt; out of the deal!&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9175526" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/pcreehan/archive/tags/Outlook/default.aspx">Outlook</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/Exchange/default.aspx">Exchange</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/MAPI/default.aspx">MAPI</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/Outlook+2007/default.aspx">Outlook 2007</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/DevMsgTeam/default.aspx">DevMsgTeam</category></item><item><title>RPC - Really Problematic Conundrum</title><link>http://blogs.msdn.com/pcreehan/archive/2008/07/15/rpc-really-problematic-conundrum.aspx</link><pubDate>Tue, 15 Jul 2008 17:49:52 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8733455</guid><dc:creator>Patrick Creehan</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/pcreehan/comments/8733455.aspx</comments><wfw:commentRss>http://blogs.msdn.com/pcreehan/commentrss.aspx?PostID=8733455</wfw:commentRss><description>&lt;p&gt;I’ve had a couple cases recently where customers were having problems getting into deadlock with one of our modules, usually MAPI or Outlook. There’s one common thread that connects these cases: message pumps. &lt;/p&gt;  &lt;p&gt;Your application has to make a remote call to a server object living in a different process or thread. Often times this is referred to as an “asynchronous” call. That term is somewhat misleading – suggesting your process could actually forget that it made the call and then be surprised when it comes back. In actuality, there’s always a listener constantly waiting for the call to return. What makes it seem asynchronous is that the waiting happens on a different thread. In order to wait for your call return, applications often implement logic called a “message pump.” This just processes incoming Windows messages or RPC calls and dispatches them to be processed; and it keeps processing messages until your call returns. &lt;/p&gt;  &lt;p&gt;The problem with this is that there’s no easy way to tell what these incoming messages are or what they’ll do. This is what gets you into trouble. &lt;/p&gt;  &lt;p&gt;Let’s say that a normal code path in one thread will go something like this:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Outlook does some work&lt;/li&gt;    &lt;li&gt;Outlook locks a critical section (CS1)&lt;/li&gt;    &lt;li&gt;Outlook calls into you&lt;/li&gt;    &lt;li&gt;You do some work&lt;/li&gt;    &lt;li&gt;You get a lock on a critical section (CS2)&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;There’s nothing wrong with this at all. Everything is fine at this point. Now lets suppose there’s a different thread that does something like this&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;You do some work&lt;/li&gt;    &lt;li&gt;You get a lock on a critical section (CS2).&lt;/li&gt;    &lt;li&gt;You make an RPC call or otherwise pump messages.&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Now, up to this point there’s nothing wrong. Suppose, however, that one of the pending messages is from Outlook and the execution goes something like this:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;…You make an RPC call…&lt;/li&gt;    &lt;li&gt;The message pump dispatches the Outlook call&lt;/li&gt;    &lt;li&gt;Outlook does some work&lt;/li&gt;    &lt;li&gt;Outlook locks a critical section (CS1).&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Again, nothing is inherently wrong with this execution path &lt;em&gt;by itself.&lt;/em&gt; However, when you combine both threads, you have critical sections being locked in reverse order – classic deadlock.&lt;/p&gt;  &lt;p&gt;Here’s a way to understand the problem: Let’s say you’re at home watching a Virginia Tech football game (There are other teams? Oh yeah, I just call them “losers.”) with a friend. You both get a hankering for a cold adult beverage. You go to the fridge, but there’s only one left. You decide to split it with your buddy, which is ok, since it’s a 40. Meanwhile, your other friends arrive with their own adult beverages and ask if anyone has an opener. Your buddy gets up and gets the bottle opener.&amp;#160; You are thinking, “OK, I have the bottle, now all I need is the bottle opener, but my buddy has it so I’ll just wait until he’s done.” You both return to your respective recliners. Your buddy is thinking, “ok, I have the opener, I guess I’ll just start opening bottles with it until my glass gets filled. Surely one of the bottles will be mine.” As he’s opening your other friends’ bottles, the thought enters his mind – my friend [you] has a bottle he needs opened – I need to get his bottle to open it for him. Since both yours and your buddy’s rear ends are plastered to their respective recliners, you have now entered adult beverage deadlock.&lt;/p&gt;  &lt;p&gt;Your buddy was keeping the bottle opener all to himself while waiting for his glass to be filled. Little did he understand that by holding the bottle opener to himself, he was preventing that from happening, since the bottle was already being held firmly in your grip. Had he relinquished control of the bottle opener, you could have easily picked it up and used it. He didn’t know that one of the bottles he had to open would be yours.&lt;/p&gt;  &lt;p&gt;So how do we prevent this problem from occurring in the first place? The key is really that your buddy didn’t know what bottles he would be opening, while waiting for his glass to be filled. He didn’t know that you were planning to split the beverage with him. What he could have done is just told your friends that the bottle opener was in the drawer instead of holding onto the bottle opener while waiting for his glass to be filled. That way, when you needed it, it would be available and as long as everyone puts it back when they’re done with it, though you may need to wait for a short time, no one will go thirsty for long.&lt;/p&gt;  &lt;p&gt;The moral of the story is that you shouldn’t make it a practice to hold onto a lock while making an RPC call or otherwise pumping messages because you don’t know what messages will arrive in your pump and what locks they will request.&lt;/p&gt;  &lt;p&gt;Secondary moral of the story: always make sure your adult beverage supply is properly maintained. &lt;/p&gt;  &lt;p&gt;Go Hokies!&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8733455" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/pcreehan/archive/tags/Outlook/default.aspx">Outlook</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/MAPI/default.aspx">MAPI</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/RPC/default.aspx">RPC</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/DevMsgTeam/default.aspx">DevMsgTeam</category></item><item><title>MAPI_E_FAILONEPROVIDER (0x8004011d) after installing Windows Server 2003 SP2</title><link>http://blogs.msdn.com/pcreehan/archive/2008/01/11/mapi-e-failoneprovider-0x8004011d-after-installing-windows-server-2003-sp2.aspx</link><pubDate>Sat, 12 Jan 2008 00:56:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7080037</guid><dc:creator>Patrick Creehan</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/pcreehan/comments/7080037.aspx</comments><wfw:commentRss>http://blogs.msdn.com/pcreehan/commentrss.aspx?PostID=7080037</wfw:commentRss><description>&lt;P&gt;Sorry for the duplication, I'm just rebranding an earlier post of mine because many people have never heard of SNP and may discount the post due to the title. If you are getting MAPI errors because of RPC connectivity problems, and you have SP2 installed for Windows Server 2003, this is probably what's affecting you, especially if you have a Broadcom NIC.&lt;/P&gt;&lt;SPAN class=userInput&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/pcreehan/archive/2007/10/16/ooh-snp.aspx"&gt;http://blogs.msdn.com/pcreehan/archive/2007/10/16/ooh-snp.aspx&lt;/A&gt; &lt;/P&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=7080037" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/pcreehan/archive/tags/Exchange/default.aspx">Exchange</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/MAPI/default.aspx">MAPI</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/Exchange+2007/default.aspx">Exchange 2007</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/DevMsgTeam/default.aspx">DevMsgTeam</category></item><item><title>HELP: Outlook 2003 Doesn't Display my HTML Body</title><link>http://blogs.msdn.com/pcreehan/archive/2008/01/10/help-outlook-2003-doesn-t-display-my-html-body.aspx</link><pubDate>Thu, 10 Jan 2008 18:46:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7061791</guid><dc:creator>Patrick Creehan</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/pcreehan/comments/7061791.aspx</comments><wfw:commentRss>http://blogs.msdn.com/pcreehan/commentrss.aspx?PostID=7061791</wfw:commentRss><description>&lt;P&gt;If you've developed a custom message store and you can't get Outlook to display RTF or HTML content, check the length of your EntryIDs. If your RTF content is really just wrapped HTML content or you are providing PR_HTML, and for some reason Outlook 2003 won't display your HTML content, it may be the length of your EntryIDs.&lt;/P&gt;
&lt;P&gt;Outlook 2003 leverages IE (mshtml) to display it's HTML content. It does this by implementing a protocol handler for the outbind:// protocol. Outbind's format leverages the EntryID of the message when creating the URL. You can probably see where I'm going here. If your entryID is longer than the allowable limit for a URL, which for IE7 is 0x200 (512) characters, then mshtml fails the load of the HTMLDocument. When that happens, Outlook says "oh, well, RTF/HTML didn't work, let's just load PR_BODY and live with that.&lt;/P&gt;
&lt;P&gt;If you've verified that your EntryID is sufficiently short enough (maybe only 100 or so characters) then you may want to look at the values you're returning in the GetProps or&amp;nbsp;QueryRows&amp;nbsp;call.&lt;/P&gt;
&lt;P&gt;This could change from version to version, but in general, you just return MAPI_E_NOT_FOUND for properties you don't support, MAPI_E_NOT_ENOUGH_MEMORY that you support but don't want to return in this GetProps call necessarily. If you return the size error for PR_BODY, PR_HTML, and PR_RTF_COMPRESSED then the RTFSync property will determine the preference on whether we use HTML or RTF. Of course, you should always be returning the value (or MAPI_E_NOT_FOUND) if asked for the property directly (as in OpenProperty or HrGetOneProp).&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=7061791" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/pcreehan/archive/tags/Outlook/default.aspx">Outlook</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/MAPI/default.aspx">MAPI</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/DevMsgTeam/default.aspx">DevMsgTeam</category></item><item><title>Folder Homepage no longer works in Outlook 2007 from MAPI store providers</title><link>http://blogs.msdn.com/pcreehan/archive/2007/12/19/folder-homepage-no-longer-works-in-outlook-2007-from-mapi-store-providers.aspx</link><pubDate>Wed, 19 Dec 2007 19:02:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6807564</guid><dc:creator>Patrick Creehan</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/pcreehan/comments/6807564.aspx</comments><wfw:commentRss>http://blogs.msdn.com/pcreehan/commentrss.aspx?PostID=6807564</wfw:commentRss><description>&lt;P&gt;If you are developing&amp;nbsp;or have developed a MAPI store provider for use in Outlook and are trying to support folder homepages in your store, you are probably familiar with the PR_FOLDER_WEBVIEWINFO property. This property is undocumented and not supported, but I'll assume for the sake of this article that you have a read/write store and you're allowing Outlook to set that property for you. :)&lt;/P&gt;
&lt;P&gt;You may have noticed that folder homepages worked in previous versions of Outlook, but don't work in Outlook 2007. This is because we are turning off folder home pages (FHP) for non-default stores by default in Outlook 2007.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.microsoft.com/default.aspx?scid=kb;EN-US;923933" mce_href="http://support.microsoft.com/default.aspx?scid=kb;EN-US;923933"&gt;You cannot add a URL to the Address box on the Home Page tab in Outlook 2007 (923933)&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Simply setting the registry key below will re-enable them:&lt;/P&gt;
&lt;P&gt;\Software\Policies\Microsoft\Office\12.0\Outlook\Security &lt;BR&gt;"NonDefaultStoreScript"=dword:00000001&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=6807564" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/pcreehan/archive/tags/Outlook/default.aspx">Outlook</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/MAPI/default.aspx">MAPI</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/Outlook+2007/default.aspx">Outlook 2007</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/DevMsgTeam/default.aspx">DevMsgTeam</category></item><item><title>Free/Busy Appointments Missing After Using CDO 1.21 to Access Calendar</title><link>http://blogs.msdn.com/pcreehan/archive/2007/12/14/free-busy-appointments-missing-after-using-cdo-1-21-to-access-calendar.aspx</link><pubDate>Fri, 14 Dec 2007 20:05:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6771177</guid><dc:creator>Patrick Creehan</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/pcreehan/comments/6771177.aspx</comments><wfw:commentRss>http://blogs.msdn.com/pcreehan/commentrss.aspx?PostID=6771177</wfw:commentRss><description>&lt;P&gt;If you have written or use an application that uses CDO 1.21 (cdo.dll) that accesses your Calendar and you have users who complain that some recurring appointments are not appearing in Free/Busy in Outlook, this may be for you. &lt;/P&gt;
&lt;P&gt;When a recurring appointment is created in Outlook, you may not realize that really this is just a singular message in the MAPI store. We commonly refer to this as the _Master_ appointment. Whenever a client application or API looks for appointments in your calendar, it will expand the Master appointment into several instances according to the recurrence pattern you set when you made it a recurring appointment. These instances of the recurring appointment are interpreted - they don't actually exist in the store. &lt;/P&gt;
&lt;P&gt;When you make a change to one of these instances, such as changing the start time or the location, or if the instance is deleted, an _exception_ item is created. The exception item is a copy of many of the properties of the master appointment which is then attached to the master appointment. When the messaging infrastructure expands the master, this exception item is included in the expansion algorithm so that when expansion occurs, you see your changes or deletions appropriately. &lt;/P&gt;
&lt;P&gt;The other change that occurs when you create an exception item is that the recurrence pattern is modified on the master appointment. The recurrence pattern is a binary MAPI property stored on the master appointment message. This binary property stores the details of the recurrence pattern as well as information regarding exception items. It is not supported to modify this property directly. You can find code available on the Internet to reverse engineer this property and modify it, but this is strictly unsupported by Microsoft. &lt;/P&gt;
&lt;P&gt;What happens in cases where this property has been improperly modified or otherwise corrupted is that one or more messaging systems (Outlook, CDO, Exchange) are unable to properly expand the appointment.&lt;/P&gt;
&lt;P&gt;This is the root cause of the issue described in the first paragraph. In one case I saw recently, the recurrence pattern had been improperly modified. Outlook and OWA clients could see the appointment just fine, with one exception. There were appointments missing in Free/Busy. We were able to determine that if Outlook was the last application to publish free/busy - that is, make a change to the calendar which caused free/busy information to be republished, then the recurring appointments would appear just fine. If a certain CDO 1.21 application was the last to access the calendar, then the appointments vanished from Free/Busy. &lt;/P&gt;
&lt;P&gt;After doing some troubleshooting, I was able to determine that the Free/Busy symptom was just a symptom of a much larger problem. When I would get the Items collection from the calendar folder, that collection did not contain my problem appointments (not even the Master appointment). When CDO 1.21 would go to publish free/busy, it would get the collection of rows from MAPI (which contained the appointment) but would then attempt to expand the recurring instances. It detected a problem with the recurrence pattern (which Outlook didn't care about or check for) and would essentially ignore that appointment. That is why the appointment did not appear in Free/Busy - CDO was ignoring it altogether.&lt;/P&gt;
&lt;P&gt;Moral of the story - respect the recurrence blob.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=6771177" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/pcreehan/archive/tags/Outlook/default.aspx">Outlook</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/MAPI/default.aspx">MAPI</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/CDO+1.21/default.aspx">CDO 1.21</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/DevMsgTeam/default.aspx">DevMsgTeam</category></item><item><title>Ooh, SNP</title><link>http://blogs.msdn.com/pcreehan/archive/2007/10/16/ooh-snp.aspx</link><pubDate>Tue, 16 Oct 2007 23:46:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5475221</guid><dc:creator>Patrick Creehan</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/pcreehan/comments/5475221.aspx</comments><wfw:commentRss>http://blogs.msdn.com/pcreehan/commentrss.aspx?PostID=5475221</wfw:commentRss><description>&lt;P&gt;We've recently been seeing an elevated number of cases where networking issues are adversely affecting performance and causing other problems with messaging technologies. The common thread in many of them is that the problem only started to occur after Windows Server 2003 SP2 was installed. I recently learned that we shipped a new feature in SP2 and turned it on by default. This new feature is called &lt;A href="http://www.microsoft.com/snp" mce_href="http://www.microsoft.com/snp"&gt;Scalable Networking Pack, or SNP&lt;/A&gt;. It was actually originally shipped as a &lt;A href="http://support.microsoft.com/kb/912222" mce_href="http://support.microsoft.com/kb/912222"&gt;download for SP1&lt;/A&gt;, but was included in SP2 by default. &lt;/P&gt;
&lt;P&gt;The Exchange team has posted an &lt;A href="http://msexchangeteam.com/archive/2007/07/18/446400.aspx" mce_href="http://msexchangeteam.com/archive/2007/07/18/446400.aspx"&gt;article&lt;/A&gt; on how SNP affects Exchange and also gives a good list of links and troubleshooting steps. &lt;/P&gt;
&lt;P&gt;SNP was built to increase performance on the networking stack, and does for newer network adapters that support it. However, for older network adapters, it can cause significant delays which cause timeout problems and connection problems leading to various problems. &lt;/P&gt;
&lt;P&gt;The basic troubleshooting steps at this point are &lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Read the Exchange team's post linked above and pages they reference so you understand the issue &lt;/LI&gt;
&lt;LI&gt;Install the hotfix at &lt;A href="http://support.microsoft.com/kb/936594" mce_href="http://support.microsoft.com/kb/936594"&gt;http://support.microsoft.com/kb/936594&lt;/A&gt; &lt;/LI&gt;
&lt;LI&gt;Upgrade your network adapter drivers to the most recent version &lt;/LI&gt;
&lt;LI&gt;
&lt;DIV&gt;Disable the SNP features by setting the following registry keys: &lt;/DIV&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt"&gt;[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters] &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt"&gt;EnableTCPChimney=dword:00000000 &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt"&gt;EnableTCPA=dword:00000000 &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt"&gt;EnableRSS=dword:00000000&lt;/SPAN&gt;&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt"&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt"&gt;&lt;STRONG&gt;UPDATE&lt;/STRONG&gt;:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt"&gt;I've just had another case where SNP was the culprit. The customer had clustered Exchange 2003 boxes with recently applied SP2. They were using backup software which was using CDOEXM to get information about the environment. These calls were failing with 0x8000FFFF (E_UNEXPECTED) but after debugging we saw that RPC was getting RPC_S_SERVER_UNAVAILABLE (1722 0x6ba) errors. This prompted me to ask about SNP. Disabling SNP via the steps above resolved the issue.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt"&gt;&lt;STRONG&gt;UPDATE (1-8-07):&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt"&gt;Yet again, another customer with clustered Exchange 2007 boxes. They had a MAPI application which was unable to OpenMsgStore on mailboxes that had migrated from Exchange 2003 (MAPI_E_FAILONEPROVIDER). Debugging the process I could see RPC_S_SERVER_UNAVAILABLE errors. Sure enough, they had SP2 installed. Disabling SNP resolved the issue. The reason nonmigrated mailboxes worked was that MAPI was just guessing the ServerDN since resolving against the DS didn't work. If the mailbox had never been migrated, this guess ended up being correct; for migrated mailboxes, it was wrong and the failure bubbled up.&lt;/SPAN&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=5475221" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/pcreehan/archive/tags/Exchange/default.aspx">Exchange</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/MAPI/default.aspx">MAPI</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/CDOEXM/default.aspx">CDOEXM</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/DevMsgTeam/default.aspx">DevMsgTeam</category></item><item><title>New Blogger on the Team: DVESPA</title><link>http://blogs.msdn.com/pcreehan/archive/2007/03/22/new-blogger-on-the-team-dvespa.aspx</link><pubDate>Thu, 22 Mar 2007 22:11:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1932561</guid><dc:creator>Patrick Creehan</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/pcreehan/comments/1932561.aspx</comments><wfw:commentRss>http://blogs.msdn.com/pcreehan/commentrss.aspx?PostID=1932561</wfw:commentRss><description>&lt;P&gt;So my boy, &lt;A class="" title="Dave Vespa's Blog" href="http://blogs.msdn.com/dvespa" mce_href="http://blogs.msdn.com/dvespa"&gt;Dave Vespa&lt;/A&gt;, has just posted his first real blog post: a good one, regarding using 32-bit MAPI on Exchange 2007 (64-bit). &lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/dvespa/archive/2007/03/22/accessing-exchange-s-extended-mapi-from-a-64-bit-process.aspx"&gt;http://blogs.msdn.com/dvespa/archive/2007/03/22/accessing-exchange-s-extended-mapi-from-a-64-bit-process.aspx&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Dave is our resident COM / Interop (among other things) guy. He's had plenty of good ideas for blog posts in the past and he'll be a good one to follow. &lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1932561" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/pcreehan/archive/tags/Exchange/default.aspx">Exchange</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/MAPI/default.aspx">MAPI</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/DevMsgTeam/default.aspx">DevMsgTeam</category></item><item><title>S/MIME Magic</title><link>http://blogs.msdn.com/pcreehan/archive/2006/09/27/s-mime-magic.aspx</link><pubDate>Thu, 28 Sep 2006 04:18:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:774719</guid><dc:creator>Patrick Creehan</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/pcreehan/comments/774719.aspx</comments><wfw:commentRss>http://blogs.msdn.com/pcreehan/commentrss.aspx?PostID=774719</wfw:commentRss><description>&lt;P&gt;I know it's been a while since I posted (for all my loyal fans!) but my wife and I had a baby last month, so we've been busy with him. Jacob Matthew is a great kid though, so I'm not apologizing, just giving you an explanation! On to business...&lt;/P&gt;
&lt;P&gt;So recently I had a case where the customer was using the Outlook Object Model to parse messages in his Inbox. That's a pretty normal thing do I thought. His problem that was on certain S/MIME (Secure MIME) messages, the Outlook Object Model bombed. Upon investigation it turned out that it was when he was accessing the Body property that the exception was thrown. So like any other Developer Support Engineer in the Messaging and Collaboration team, I cracked that message open with our favorite tool, &lt;A href="http://www.codeplex.com/mfcmapi" mce_href="http://www.codeplex.com/mfcmapi"&gt;MFCMapi&lt;/A&gt;, written by my colleague, the renowned Stephen Griffin. Not only is the guy a MAPI genious, he also seems to remember every TV show or movie he has ever seen and who was in it.&lt;/P&gt;
&lt;P&gt;Back to the story...&lt;/P&gt;
&lt;P&gt;So there I was knee-deep in MFCMAPI and I'm looking at this message. I have some other S/MIME messages in my mailbox so I can compare them. So as I'm looking at the PR_ props of my problem message and I notice that I don't see the PR_HTML property...in a flutter of panic, I look for the PR_BODY property...nothing. Well, that's ok, often times messages get stuffed into the PR_RTF_COMPRESSED property. And that would be fine and good, except that that property was missing also. DUN DUN DUUUUNNNN...&lt;/P&gt;
&lt;P&gt;So where is the message? I can see it in Outlook, but it doesn't appear to be in any properties in the MAPI message.&lt;/P&gt;
&lt;P&gt;Then it hit me...this message carries a copy of itself in a hidden&amp;nbsp;attachment called smime.p7m. This helps ensure that the message content does not change since whoever signed the message originally originally signed the message. I opened up the attachment and sure enough, the content of the message was in a property called PR_ATTACHMENT_DATA_OBJ. Well that clears up one mystery. This doesn't necessarily explain why the Outlook Object Model throws an exception.&lt;/P&gt;
&lt;P&gt;Well, this story doesn't have a really happy ending. I'm not sure why the Body property fails...I know that it happens in source when the HTML stream is being copied into the Text stream, but that's all I know. What I do know is that the HTMLBody works. So if you find an exception gets thrown when you are trying to access the Body property on a message object, try hitting the HTMLBody property as a backup and strip out the HTML tags yourself using regular expressions or something like that. &lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=774719" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/pcreehan/archive/tags/Outlook/default.aspx">Outlook</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/MAPI/default.aspx">MAPI</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/MIME/default.aspx">MIME</category><category domain="http://blogs.msdn.com/pcreehan/archive/tags/DevMsgTeam/default.aspx">DevMsgTeam</category></item></channel></rss>