• Sign in
 
  •  
  • MSDN Blogs
  • Microsoft Blog Images
  • More ...

  • Blog Home
  • About
  • Email Blog Author
  • Share this
  • RSS for posts
  • Atom
  • RSS for comments
  • CDO (25)
  • Code Snippet (43)
  • Custom Providers (17)
  • Debugging (7)
  • DevMsgTeam (303)
  • Documentation (111)
  • DST (8)
  • EWS (7)
  • Exchange (110)
  • Gotchas (98)
  • Hotfix (28)
  • MAPI (241)
  • MAPI Download (55)
  • MFCMAPI (102)
  • MSDN (59)
  • Non Dev (11)
  • OOM (17)
  • Outlook (171)
  • Outlook 2007 Auxiliary Reference (45)
  • Outlook Integration API (12)
  • Protocol Docs (20)
  • PST/OST (23)
  • Referrals (8)
  • Vista (12)
  • WrapPST (18)
Links:
  • Download MFCMAPI
  • MFCMAPI on Facebook
  • Troubleshooting Outlook Crashes
  • Office Update Center
  • Developer Messaging Team Blog
This site is provided "AS IS" with no warranties, and confers no rights. Use of included code samples are subject to the terms specified in the Terms of Use.
Archives
  • May 2013 (5)
  • April 2013 (1)
  • March 2013 (2)
  • February 2013 (2)
  • January 2013 (2)
  • December 2012 (4)
  • November 2012 (2)
  • October 2012 (2)
  • September 2012 (1)
  • August 2012 (3)
  • June 2012 (2)
  • May 2012 (1)
  • April 2012 (3)
  • March 2012 (3)
  • February 2012 (3)
  • January 2012 (1)
  • December 2011 (3)
  • November 2011 (1)
  • October 2011 (3)
  • September 2011 (1)
  • August 2011 (1)
  • July 2011 (4)
  • June 2011 (3)
  • May 2011 (3)
  • April 2011 (3)
  • March 2011 (5)
  • February 2011 (1)
  • January 2011 (2)
  • December 2010 (1)
  • November 2010 (4)
  • October 2010 (1)
  • September 2010 (3)
  • August 2010 (5)
  • July 2010 (3)
  • June 2010 (3)
  • May 2010 (1)
  • April 2010 (3)
  • March 2010 (3)
  • February 2010 (3)
  • January 2010 (2)
  • December 2009 (3)
  • November 2009 (5)
  • October 2009 (4)
  • September 2009 (5)
  • August 2009 (5)
  • July 2009 (11)
  • June 2009 (6)
  • May 2009 (5)
  • April 2009 (3)
  • March 2009 (18)
  • February 2009 (10)
  • January 2009 (3)
  • December 2008 (2)
  • November 2008 (2)
  • October 2008 (5)
  • September 2008 (4)
  • August 2008 (10)
  • July 2008 (6)
  • June 2008 (8)
  • May 2008 (2)
  • April 2008 (4)
  • March 2008 (2)
  • February 2008 (2)
  • January 2008 (5)
  • December 2007 (3)
  • November 2007 (2)
  • October 2007 (3)
  • September 2007 (1)
  • August 2007 (4)
  • July 2007 (5)
  • June 2007 (3)
  • May 2007 (4)
  • April 2007 (1)
  • March 2007 (6)
  • February 2007 (3)
  • January 2007 (2)
  • December 2006 (4)
  • November 2006 (3)
  • October 2006 (1)
  • August 2006 (1)
  • June 2006 (5)
  • May 2006 (5)
  • December 2005 (1)
  • November 2005 (4)
  • October 2005 (2)
  • September 2005 (1)
  • April 2005 (3)
  • December 2004 (2)
  • September 2004 (2)
  • August 2004 (3)
  • July 2004 (3)

Unicode MSG Files

MSDN Blogs > SGriffin's MAPI Internals > Unicode MSG Files

Unicode MSG Files

Stephen Griffin - MSFT
25 May 2006 10:16 AM
  • Comments 21

[This is now documented here: http://msdn.microsoft.com/en-us/library/bb820947.aspx]

There was a thread a while back in the microsoft.public.win32.programmer.messaging newsgroup about how Outlook 2003's new Unicode MSG files. The big question was how to create one. One poster even went as far as to reverse engineer the MSG format from scratch. Fortunately, there's an easier way, which I just got clearance to publish.

We start with the canonical sample for MSG files:
http://support.microsoft.com/kb/171907

The key is the OpenIMsgOnIStg function. This function takes a ulFlags parameter. All you need to do to create a Unicode MSG file is to pass MAPI_UNICODE in this parameter. Once you do that, the resulting message will show STORE_UNICODE_OK in it's PR_STORE_SUPPORT_MASK and unicode properties will work.

This flag is supported in this function on Outlook 2003 and higher only.

  • 21 Comments
Outlook, MAPI, Documentation, Outlook 2007 Auxiliary Reference, DevMsgTeam, MSDN
Comments
  • Pete Maclean
    25 May 2006 1:35 PM
    I note that if this flag is used when an older version of Outlook is installed, OpenIMsgOnIStg fails with MAPI_E_UNKNOWN_FLAGS.  This would seem to accord with Stephen's statement, "This flag is supported in this function on Outlook 2003 and higher only".  The important thing is that the error is not MAPI_E_BAD_CHARWIDTH as one might otherwise suspect.  
  • scott mcfadden
    15 Apr 2007 11:15 AM

    I noticed that when using extended MAPI to persist emails with large recipient counts to disk, it takes a very long time and the resultant msg file is quite large.  However, it appears that if you save the email / msg to disk using Unicode, the operation goes much faster and the msg file is much smaller.  Why is this?

    thanks

  • Tim Valez
    8 Aug 2007 4:40 PM

    I'm testing this with Outlook 2007 and OpenIMsgOnIStg() returns MAPI_E_UNKNOWN flags. Puzzling, this is the behavior one would expect from anything older than Outlook 2003 but definitely not from OL2K7. Any ideas?

  • Stephen Griffin - MSFT
    8 Aug 2007 5:17 PM

    The flag is definitely supported with 2007. Have you tried the same code and just dropped that flag to make sure it's not something else in your code triggering the problem?

  • Tim Valez
    9 Aug 2007 10:27 AM

    Yes, I tried that and it works: without the flag it creates a valid .MSG in the old format that I can load from Outlook. I also tried from OutlookSpy with same results, Dmitry's code fails to save IMessage objects as Unicode MSG files. It won't display any errors but the just created file is only 2.5KB long and won't load in Outlook.

  • Tim Valez
    16 Oct 2007 11:39 PM

    Update: when I wrote a simple test program that used OpenIMsgOnStg() it worked as expected and I was able to create Unicode .MSG files.

    But the very same code will fail returning MAPI_E_UNKNOWN when executed in my Outlook extension (ECE)!? This reminded me of that old friend (or foe?) the MAPI32 stub DLL...

    The implementation of MAPI loaded for the test program resides in MSMAPI32.DLL and works as reported by Stephen.

    The version of OpenMsgOnIStg() loaded by Outlook 2007 is implemented by OLMAPI32.DLL and does not seem to support the MAPI_UNICODE flag.

    So I managed to work around it by dynamically loading MSMAPI32.DLL in my ECE. But now I'm curious... why Outlook 2007 needs a separate implementation of MAPI?

  • Stephen Griffin - MSFT
    17 Oct 2007 11:40 AM

    Tim - the implementation of OpenIMsgOnIStg in msmapi32.dll is just a stub that ensures olmapi32.dll is loaded and then jumps directly into olmapi32!OpenIMsgOnIStg. It doesn't do any parameter checking or manipulation. So that shouldn't be any reason for a difference in behavior. I suspect there's still something else going on here.

  • Tim Valez
    17 Oct 2007 9:11 PM

    Stephen - obviously I did not manage to communicate my point. I do understand how msmapi32.dll works (just a stub). What I'm saying is:

    msmapi32!IOpenIMsgOnIStg -> supports the MAPI_UNICODE flag

    olmapi32!IOpenIMsgOnIStg -> does not work, returns MAPI_E_UNKNOWN_FLAGS

    That's why my simple test program worked (msmapi32 was loaded by the stub DLL) but exactly the same code failed when executed from my ECE (olmapi32 was loaded by the stub DLL).

    You can confirm this by directly loading msmapi32!OpenIMsgOnIStg and olmapi32!OpenIMsgOnIStg via LoadLibrary/GetProcAddress and comparing the results.

    As I said in my previous post, the existence of two MAPI implementations (msmapi32.dll and olmapi32.dll) picked my curiosity. Why do we need two of them?Outlook 2003 uses msmapi32.dll, I've never heard of olmapi32.dll before Outlook 2007...

  • Stephen Griffin - MSFT
    17 Oct 2007 10:51 PM

    There aren't two implementations. Many applications have hardcoded a path to msmapi32.dll, so for 2007 when we moved our MAPI implementation to olmapi32.dll we left a stub there so as not to break anyone. The stub doesn't do anything but pass the call on to olmapi32. And this is where I have a problem with your logic:

    How could a stub support a flag when the underlying library, the one that actually does the work, doesn't support it? The only way that would make sense is if the stub did something to the parameters before calling the underlying libraries, and I already verified both in the code and in the debugger that is not the case.

    There HAS to be something else going on. What are the paths to msmapi32.dll and olmapi32.dll that you're loading in your tests?

  • SGriffin's [MSFT] WebLog
    8 Jan 2008 11:24 AM

    Whenever I find myself repeating the same message over and over again, I have to ask why I haven't blogged

  • pcunite
    1 May 2008 8:48 PM

    This does not work on Exchange's version of mapi nor with the new ExchangeMapiCdo.

  • David Lowndes
    29 Jul 2008 9:00 AM

    Hi Steven,

    What's the situation with using MAPI_UNICODE with OpenIMsgOnIStg on Exchange server (2003)?

    I'm working on an Exchange gateway that needs to support Unicode MAPI. The message I get from Exchange's MTS_OUT queue allow me to GetProps as Unicode, but our gateway creates an intermediate MSG file using StgCreateDocfile & OpenIMsgOnIStg, and if I specify the unicode flag with that, it fails with MAPI_E_UNKNOWN_FLAGS.

    Is there a server MAPI update that allows me to create Unicode MSG files on Exchange server?

    Assuming there isn't, what other viable options are there?

    Thanks

    Dave Lowndes

  • Stephen Griffin - MSFT
    29 Jul 2008 9:16 AM

    Exchange's MAPI doesn't support unicode MSG files. Like I said - only Outlook 2003 and higher.

  • David Lowndes
    29 Jul 2008 10:45 AM

    So, is there is no alternative easy way to create a Unicode MSG file on Exchange server 2003?

  • Stephen Griffin - MSFT
    29 Jul 2008 10:54 AM

    No way period.

Page 1 of 2 (21 items) 12
Leave a Comment
  • Please add 3 and 5 and type the answer here:
  • Post
  • © 2013 Microsoft Corporation.
  • Terms of Use
  • Trademarks
  • Privacy & Cookies
  • Report Abuse
  • 5.6.426.415