| Platform SDK: Exchange 2000 Server |
[This is preliminary documentation and subject to change.]
To load a serialized message into a CDO Message object from within an ADO Stream object, perform the following steps:
' Reference to Microsoft ActiveX Data Objects 2.5 Library
' Reference to Microsoft CDO for Exchange 2000 Server Library
' ..
Function LoadMessageFromFile(Path As String) As Message
Dim Stm As New Stream
Stm.Open
Stm.LoadFromFile Path
Dim iMsg As New CDO.Message
Dim iDsrc As IDataSource
Set iDsrc = iMsg
iDsrc.OpenObject Stm, "_Stream"
Set LoadMessageFromFile = iMsg
End Function
#import "c:\program files\common files\system\ado\msado15.dll" no_namespace
#import "c:\exchsrvr\cdoex.dll" no_namespace
// ...
IMessagePtr Load_Message_from_File(_bstr_t path)
{
/*
** This example shows a common use of the ADO Stream
** object with CDO, namely, opening a serialized
** message from a file on disk and loading it into
** a CDO Message object.
**/
_StreamPtr pStm(__uuidof(Stream));
_variant_t varOptional(DISP_E_PARAMNOTFOUND,VT_ERROR);
try {
pStm->raw_Open(varOptional, adModeUnknown, adOpenStreamUnspecified,NULL,NULL);
pStm->LoadFromFile(path);
}
catch(_com_error e)
{
throw e;
}
IMessagePtr iMsg(__uuidof(Message));
IDataSourcePtr iDsrc;
iDsrc = iMsg;
try {
iDsrc->OpenObject(pStm,_bstr_t("_Stream"));
}
catch(_com_error e)
{
throw e;
}
// ....
return iMsg;
}
Function LoadMessageFromFile(Path) As Message
Dim Stm
Set Stm = CreateObject("ADODB.Stream")
Stm.Open
Stm.LoadFromFile Path
Dim iMsg
Set iMsg = CreateObject("CDO.Message")
Dim iDsrc
Set iDsrc = iMsg
iDsrc.OpenObject Stm, "_Stream"
Set LoadMessageFromFile = iMsg
End Function