D
Daniel
I'm trying to put RTF formatted text into the body of an appointment item.
I've found various examples on the web but I'm still having some problems.
Using Outlook spy, I can see that the code I use below does indeed put rtf
into the PR_RTF_COMPRESSED property. Yet I see nothing in the body. Does
anyone see anything wrong with what I'm doing below?
m_pAppointment is an Outlook::_AppointmentItem
m_pWrapRTFStream is a pointer to WrapCompressedRTFStream. Typedef is below
m_pRTFSync if a pointer to RTFSync. Typedef is below
typedef HRESULT (STDAPICALLTYPE *PwrapCompressedRTFStreamPtr)(
LPSTREAM lpCompressedRTFStream,
ULONG ulFlags,
LPSTREAM* lppUncompressedRTFStream);
typedef HRESULT (STDAPICALLTYPE *pRTFSyncPtr)(
LPMESSAGE lpMessage,
ULONG ulFlags,
BOOL* lpbMessageUpdated
);
--------------code starts
CComPtr<IUnknown> pUnk;
CComPtr<IStream> lpStreamRTFCompDest = NULL;
CComPtr<IStream> lpStreamRTFDest = NULL;
ULONG cbRead = 0;
BOOL fUpdated = FALSE ;
hr = m_pAppointment->get_MAPIOBJECT (&pUnk);
if (SUCCEEDED(hr))
{
CComPtr<IMessage> pMessage;
hr = pUnk->QueryInterface(IID_IMessage, (void **)&pMessage);
if (SUCCEEDED(hr))
{
hr = pMessage->OpenProperty(PR_RTF_COMPRESSED, // property to open
&IID_IStream,
0,
MAPI_CREATE | MAPI_MODIFY | MAPI_DEFERRED_ERRORS,
(LPUNKNOWN *)&lpStreamRTFCompDest);
if (SUCCEEDED(hr))
{
hr = m_pWrapRTFStream(lpStreamRTFCompDest,
MAPI_MODIFY | STORE_UNCOMPRESSED_RTF,
&lpStreamRTFDest);
CComBSTR rtStr(TEXT("{\\rtf1\\ansi{\\fonttbl\\f0\\fswiss
Helvetica;}\\f0\\par This is some {\\b bold} text.\\par}"));
hr = lpStreamRTFDest->Write(rtStr, rtStr.ByteLength(), &cbRead);
hr = lpStreamRTFDest->Commit(STGC_OVERWRITE) ;
hr = m_pRTFSync(pMessage, RTF_SYNC_RTF_CHANGED, &fUpdated);
}
}
}
I've found various examples on the web but I'm still having some problems.
Using Outlook spy, I can see that the code I use below does indeed put rtf
into the PR_RTF_COMPRESSED property. Yet I see nothing in the body. Does
anyone see anything wrong with what I'm doing below?
m_pAppointment is an Outlook::_AppointmentItem
m_pWrapRTFStream is a pointer to WrapCompressedRTFStream. Typedef is below
m_pRTFSync if a pointer to RTFSync. Typedef is below
typedef HRESULT (STDAPICALLTYPE *PwrapCompressedRTFStreamPtr)(
LPSTREAM lpCompressedRTFStream,
ULONG ulFlags,
LPSTREAM* lppUncompressedRTFStream);
typedef HRESULT (STDAPICALLTYPE *pRTFSyncPtr)(
LPMESSAGE lpMessage,
ULONG ulFlags,
BOOL* lpbMessageUpdated
);
--------------code starts
CComPtr<IUnknown> pUnk;
CComPtr<IStream> lpStreamRTFCompDest = NULL;
CComPtr<IStream> lpStreamRTFDest = NULL;
ULONG cbRead = 0;
BOOL fUpdated = FALSE ;
hr = m_pAppointment->get_MAPIOBJECT (&pUnk);
if (SUCCEEDED(hr))
{
CComPtr<IMessage> pMessage;
hr = pUnk->QueryInterface(IID_IMessage, (void **)&pMessage);
if (SUCCEEDED(hr))
{
hr = pMessage->OpenProperty(PR_RTF_COMPRESSED, // property to open
&IID_IStream,
0,
MAPI_CREATE | MAPI_MODIFY | MAPI_DEFERRED_ERRORS,
(LPUNKNOWN *)&lpStreamRTFCompDest);
if (SUCCEEDED(hr))
{
hr = m_pWrapRTFStream(lpStreamRTFCompDest,
MAPI_MODIFY | STORE_UNCOMPRESSED_RTF,
&lpStreamRTFDest);
CComBSTR rtStr(TEXT("{\\rtf1\\ansi{\\fonttbl\\f0\\fswiss
Helvetica;}\\f0\\par This is some {\\b bold} text.\\par}"));
hr = lpStreamRTFDest->Write(rtStr, rtStr.ByteLength(), &cbRead);
hr = lpStreamRTFDest->Commit(STGC_OVERWRITE) ;
hr = m_pRTFSync(pMessage, RTF_SYNC_RTF_CHANGED, &fUpdated);
}
}
}