Changing RTF Body on MailItem Read event

  • Thread starter Thread starter adobrzanski
  • Start date Start date
A

adobrzanski

I'm developing Outlook 2003 addin in c#.
I need to add/replace rtf body of a MailItem that is just being read
(mail_read event is triggered for that MailItem). I'm able to
successfully add/replace the RTF content (using PR_RTF_COMPRESSED and
WrapCompressedRTFStream passing MAPIOBJECT to small C++ code). I know
that I should dereference completely this item for the changes to take
place (for outlook to display added rtf). But can I do that on
mail_read event? Or is it too late?
Now I do dereference MailItem on read_event. But RTF is not being
displayed.

If I cancel mail_open event just after mail_read and cancel it
(Inspector is not displayed) and User openes this MailItem again, it
gives correct RTF body (just as I want it).
But I need to do this runtime. Canceling mail_open and then again
finding MailItem by EntryID and doing MailItem.Display() doesn't show
correct RTF body.

Any Ideas?
Thanks in advance
Alek
 
Can't do that. When Outlook is opening a message, you cannot make Outlook
refresh its internal cache short of canceling the whole process.
Looks like what you really need is a custom form.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
Thanks Dmitry for your answer.
Can't do that. When Outlook is opening a message, you cannot make Outlook
refresh its internal cache short of canceling the whole process.
That's what I was afraid of.
Looks like what you really need is a custom form.
I will investigate the use of custom forms. If you have any good
internet resources on that subject I will appreciate if you could share
it with me.

Thanks,
Alek
 
Back
Top