OpenIMsgSession

Applies to: Outlook 2013 | Outlook 2016

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

Property Value
Header file:
Imessage.h
Implemented by:
MAPI
Called by:
Client applications and service providers
SCODE OpenIMsgSession(
  LPMALLOC lpMalloc,
  ULONG ulFlags,
  LPMSGSESS FAR * lppMsgSess
);

Parameters

lpMalloc

[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.

ulFlags

[in] Reserved; must be zero.

lppMsgSess

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

Return value

S_OK

The session was opened.

MAPI_E_INVALID_PARAMETER

lpMalloc or lppMsgSess is NULL.

MAPI_E_INVALID_FLAGS

Invalid flags were passed.

MAPI_UNICODE

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.

Remarks

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.