Last modified: July 23, 2011

Applies to: Outlook

Closes a message session and all the messages created within that session.

Header file:


Implemented by:


Called by:

Client applications and service providers

VOID CloseIMsgSession(


[in] Pointer to the message session object obtained using the OpenIMsgSession function at the start of the message session.

A message session is used by client applications and service providers that want to deal with several related MAPI IMessage 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 opened 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.