OpenIMsgOnIStg
The OpenIMsgOnIStg
function creates internal memory structures and an object handle for creation
of a new message object.
Quick Info
Header
file: |
IMESSAGE.H |
Implemented
by: |
MAPI |
Called by: |
Client
applications and service providers |
SCODE OpenIMsgOnIStg(
LPMSGSESS lpMsgSess, |
|
LPALLOCATEBUFFER lpAllocateBuffer, |
|
LPALLOCATEMORE lpAllocateMore, |
|
LPFREEBUFFER lpFreeBuffer, |
|
LPMALLOC lpmalloc, |
|
LPVOID lpMapiSup, |
|
LPSTORAGE lpStg, |
|
MSGCALLRELEASE FAR * lpfMsgCallRelease, |
|
ULONG ulCallerData, |
|
ULONG ulFlags, |
|
LPMESSAGE FAR * lppMsg |
|
); |
|
Parameters
lpMsgSess
[in] Pointer
to a message session object.
lpAllocateBuffer
[in] Pointer
to the MAPIAllocateBuffer
lpAllocateMore
[in] Pointer
to the MAPIAllocateMore
lpFreeBuffer
[in] Pointer
to the MAPIFreeBuffer
lpMalloc
[in] Pointer
to a memory allocator object exposing the OLE IMalloc interface. The
message object may need to use this allocation method when working with certain
interfaces such as IStream.
lpMapiSup
[in] Pointer
to an optional MAPI support object used when a service provider calls OpenIMsgOnIStg.
lpStg
[in, out]
Pointer to an IStorage object that is open and has read/write access.
Because messages do not support write-only access, OpenIMsgOnIStg does
not accept a storage object opened with write-only access.
lpfMsgCallRelease
[in] Pointer
to a message-release callback function in the service provider DLL.
ulCallerData
[in] Caller
data to be written by the callback function indicated by the lpfMsgCallRelease
parameter.
ulFlags
[in] Bitmask of flags used to control whether the OLE IStorage::Commit
method is called when the client application calls the IMessage::SaveChanges
method. The following flag can be set:
IMSG_NO_ISTG_COMMIT
Controls whether
the OLE method IStorage::Commit is called when the client calls SaveChanges
lppMsg
[out] Pointer
to a pointer to the opened message object.
Return Values
S_OK
The call
succeeded and has returned the expected value or values.
Warning The correct
process for defining a message attachment is to call the IMAPIProp::OpenProperty method with a source
interface of IMessage : IMAPIProp . IMAPIProp::OpenProperty is also
supported for message attachments when the source interface is the OLE
interface IStorage. IStorage is supported to allow an easy way to
put a Microsoft Word for Windows document into an attachment without converting
the attachment to or from the OLE IStream interface. However, use of IStorage
presents a danger to the predictability of IMessage when the client
application or service provider passes a new attachment data pointer to OpenIMsgOnIStg
and then releases objects in the wrong order.
Including the
lpMsgSess parameter ensures that the new message is created within a
session so that it can be closed when the session is closed. If lpMsgSess
is NULL, a message is created independently of any session. If the client or
service provider that created the message does not release the message or does
not release open tables within the message, memory is leaked until the external
application terminates.
The lpAllocateBuffer,
lpAllocateMore, and lpFreeBuffer input parameters point to the MAPIAllocateBuffer
If a value is
supplied for lpMapiSup, IMessage supports the MAPI_DIALOG and
ATTACH_DIALOG flags by calling the IMAPISupport::DoProgressDialogC0WT.7 and making calls on the resulting address
book object. If zero is passed for lpMapiSup, IMessage ignores
MAPI_DIALOG and ATTACH_DIALOG and stores short-term entry identifiers without
conversion.
MAPI does not
define the behavior of multiple open operations performed on a message
subobject, such as an attachment, a stream, a message store, or another
message. MAPI currently allows a subobject that is already open to be opened
once more, but MAPI performs the open operation by incrementing the reference
count for the existing open object and returning it to the client or provider
that called the IMessage::OpenAttach method
Some clients
of IMessage might call the OLE method IStorage::Commit after
writing data beyond what IMessage itself writes to the storage object.
To aid in this, the IMessage implementation guarantees to name all
substorages. Therefore, if the client keeps its names out of that namespace,
there will be no accidental collisions.
The callback
function mentioned with the lpfMsgCallRelease parameter is optional; if
provided, it should be based on the MSGCALLRELEASE
See Also
OpenIMsgSession