Board index » delphi » Setting RTF body of an Appointment item in Outlook

Setting RTF body of an Appointment item in Outlook

Hello all,
I have the following problem. I need to create an Appointment or Task item
in Outlook and set its body with RTF formatting. I know how to create the
item with Outlook object mode, but I see that Outlook object model does not
provide access to the RTF body and thus I need to get down to MAPI level. I
thought I could get the IMessage interface of the Appointment item from its
Outlook _AppointmentItem inteface by calling
AppointmentItem.MapiObject.QueryInterface with IMessage IID. But this
QueryInterface fails with E_FAIL return code. Can anyone comment why this
happens?

I tried a different route. I start a new MAPI session with MAPILogonEx, open
the message store that contains my Appointment with Session.OpenMsgStore
(passing MAPI_MODIFY for flags, since I need to modify my Appointment), and
then use the store object to get to my Appointment with MsgStore.OpenEntry,
again passing MAPI_MODIFY flag. This fails with MAPI_E_NO_ACCESS. The folder
where the Appointment is located is my personal Calendar folder, so I have
all access rights for it. If I try to do MsgStore.OpenEntry without
MAPI_MODIFY flag, the call successds, but then, obviously, I cannot modify
the Appointment.

Any help would be appreciated. Thanks.

Leonid.

 

Re:Setting RTF body of an Appointment item in Outlook


1. If your code is running in a thread other than the main Outlook thread
(i.e. your code in not in an addin), you need to call MAPIInitalize() before
doing anything MAPI related, including QI'ing for IMessage.
2. I don't think MAPI_MODIFY is a valid flag for
IMAPISession.OpenMsgStore(). Try MAPI_BEST_ACCESS or MDB_WRITE instead.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool

Quote
"Leonid Zeitlin" <l...@csltd.com.ua> wrote in message

news:3efb2f94@newsgroups.borland.com...
Quote
> Hello all,
> I have the following problem. I need to create an Appointment or Task item
> in Outlook and set its body with RTF formatting. I know how to create the
> item with Outlook object mode, but I see that Outlook object model does
not
> provide access to the RTF body and thus I need to get down to MAPI level.
I
> thought I could get the IMessage interface of the Appointment item from
its
> Outlook _AppointmentItem inteface by calling
> AppointmentItem.MapiObject.QueryInterface with IMessage IID. But this
> QueryInterface fails with E_FAIL return code. Can anyone comment why this
> happens?

> I tried a different route. I start a new MAPI session with MAPILogonEx,
open
> the message store that contains my Appointment with Session.OpenMsgStore
> (passing MAPI_MODIFY for flags, since I need to modify my Appointment),
and
> then use the store object to get to my Appointment with
MsgStore.OpenEntry,
> again passing MAPI_MODIFY flag. This fails with MAPI_E_NO_ACCESS. The
folder
> where the Appointment is located is my personal Calendar folder, so I have
> all access rights for it. If I try to do MsgStore.OpenEntry without
> MAPI_MODIFY flag, the call successds, but then, obviously, I cannot modify
> the Appointment.

> Any help would be appreciated. Thanks.

> Leonid.

Re:Setting RTF body of an Appointment item in Outlook


Dmitry, thanks a lot for your tip to call MAPIInitalize before requesting
IMessage interface. That did the trick.

Thanks,
   Leonid

"Dmitry Streblechenko" <dmi...@dimastr.com> ???Y/???Y ?????
???Y??: news:3efb36a4$1@newsgroups.borland.com...

Quote
> 1. If your code is running in a thread other than the main Outlook thread
> (i.e. your code in not in an addin), you need to call MAPIInitalize()
before
> doing anything MAPI related, including QI'ing for IMessage.
> 2. I don't think MAPI_MODIFY is a valid flag for
> IMAPISession.OpenMsgStore(). Try MAPI_BEST_ACCESS or MDB_WRITE instead.

> Dmitry Streblechenko (MVP)
> http://www.dimastr.com/
> OutlookSpy  - Outlook, CDO
> and MAPI Developer Tool

> "Leonid Zeitlin" <l...@csltd.com.ua> wrote in message
> news:3efb2f94@newsgroups.borland.com...
> > Hello all,
> > I have the following problem. I need to create an Appointment or Task
item
> > in Outlook and set its body with RTF formatting. I know how to create
the
> > item with Outlook object mode, but I see that Outlook object model does
> not
> > provide access to the RTF body and thus I need to get down to MAPI
level.
> I
> > thought I could get the IMessage interface of the Appointment item from
> its
> > Outlook _AppointmentItem inteface by calling
> > AppointmentItem.MapiObject.QueryInterface with IMessage IID. But this
> > QueryInterface fails with E_FAIL return code. Can anyone comment why
this
> > happens?

> > I tried a different route. I start a new MAPI session with MAPILogonEx,
> open
> > the message store that contains my Appointment with Session.OpenMsgStore
> > (passing MAPI_MODIFY for flags, since I need to modify my Appointment),
> and
> > then use the store object to get to my Appointment with
> MsgStore.OpenEntry,
> > again passing MAPI_MODIFY flag. This fails with MAPI_E_NO_ACCESS. The
> folder
> > where the Appointment is located is my personal Calendar folder, so I
have
> > all access rights for it. If I try to do MsgStore.OpenEntry without
> > MAPI_MODIFY flag, the call successds, but then, obviously, I cannot
modify
> > the Appointment.

> > Any help would be appreciated. Thanks.

> > Leonid.

Other Threads