A Microsoft Outlook email forum. Outlook Banter

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.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

RTF in an outlook appointment item



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old April 4th 07, 04:59 PM posted to microsoft.public.outlook.program_addins
Daniel
external usenet poster
 
Posts: 5
Default 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);

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

}



 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
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


All times are GMT +1. The time now is 08:47 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.