View Single Post
  #2  
Old April 4th 07, 06:36 PM posted to microsoft.public.outlook.program_addins
Daniel
external usenet poster
 
Posts: 5
Default RTF in an outlook appointment item

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




"Daniel" wrote in message
...
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
CComPtrIUnknown pUnk;
CComPtrIStream lpStreamRTFCompDest = NULL;
CComPtrIStream lpStreamRTFDest = NULL;
ULONG cbRead = 0;
BOOL fUpdated = FALSE ;

hr = m_pAppointment-get_MAPIOBJECT (&pUnk);
if (SUCCEEDED(hr))
{
CComPtrIMessage 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);
}
}

}



Ads