Changing RTF Body on MailItem Read event

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
 
D

Dmitry Streblechenko

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
 
A

adobrzanski

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top