Collapse the table of content
Expand the table of content
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer


Last modified: February 09, 2010

Applies to: Office 2010 | Outlook 2010 | Visual Studio

Creates and opens a message session that groups the messages created within it.

Header file:


Implemented by:


Called by:

Client applications and service providers

SCODE OpenIMsgSession(
  LPMALLOC lpMalloc,
  ULONG ulFlags,
  LPMSGSESS FAR * lppMsgSess


[in] Pointer to a memory allocator object exposing the OLE IMalloc interface. MAPI needs to use this allocation method when working with the OLE IStorage interface.


[in] Reserved; must be zero.


[out] Pointer to a pointer to the returned message session object.


The session was opened.


lpMalloc or lppMsgSess is NULL.


Invalid flags were passed.


When calling this function, a client or service provider sets the MAPI_UNICODE flag to create Unicode .msg files. The resulting Imessage file shows STORE_UNICODE_OK in its PR_STORE_SUPPORT_MASK and supports Unicode properties.

A message session is used by client applications and service providers that want to deal with several related MAPI IMessage : IMAPIProp objects built on top of underlying OLE IStorage objects. The client or provider uses the OpenIMsgSession and CloseIMsgSession functions to wrap the creation of such messages inside a message session. Once the message session is opened, the client or provider passes a pointer to it in a call to OpenIMsgOnIStg to create a new IMessage-on-IStorage object.

A message session keeps track of all IMessage-on-IStorage objects created during the duration of the session, in addition to all the attachments and other properties of the messages. When a client or provider calls CloseIMsgSession, it closes all these objects. Calling CloseIMsgSession is the only way to close IMessage-on-IStorage objects.

OpenIMsgSession is used by clients and providers that require the ability to handle several related messages as OLE IStorage objects. If only one such message is to be open at a time, there is no need to track multiple messages and no reason to create a message session with OpenIMsgSession.

Because it is dealing with an underlying OLE object, MAPI needs to use OLE memory allocation. For more information about OLE structured storage objects and OLE memory allocation, see OLE and Data Transfer.

© 2015 Microsoft