![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
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 |
#2
|
|||
|
|||
![]()
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); } } } |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to change an item from a recurring Appointment item to an exception from VB code? | Dikbill | Outlook and VBA | 2 | July 13th 06 08:45 AM |
Saving exception item in recurring appointment item fails | Dikbill | Outlook and VBA | 2 | July 11th 06 03:59 PM |
Saving exception item in recurring appointment item fails | Dikbill | Outlook - Calandaring | 0 | July 11th 06 02:01 PM |
How can I create a outlook appointment item from data in a e-mail? | StoltHD | Outlook and VBA | 6 | June 17th 06 08:00 AM |
How can I create a outlook appointment item from data in a e-mail? | Eric Legault [MVP - Outlook] | Outlook and VBA | 0 | June 15th 06 06:23 PM |