RTF in an outlook appointment item



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);

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
(LPUNKNOWN *)&lpStreamRTFCompDest);

if (SUCCEEDED(hr))
hr = m_pWrapRTFStream(lpStreamRTFCompDest,

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);



Well part of the problem is incorrectly formatted text. Changing the text
and how I write it to below, gives me text which I can read more clearly in
OutlookSpy. But still nothing in the body of the appointment.

LPSTR cRTF= "{\\rtf1\\ansi{\\fonttbl\\f0\\fswiss Helvetica;}\\f0\\par This
is some {\\b bold} text.\\par}";

hr = lpStreamRTFDest->Write(cRTF, strlen(cRTF), &cbRead);

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question