Outlook add-in, MS Word problem

D

Dennis Masko

Hello,

I'm implementing Outlook COM add-in for MS Office 2003 SP2 with VC++
6.0.

A part of the functionality does the following: in NewInspector event
of Inspectors collection obtained COM interface "insp" is used to
get mail item edited by newly created inspector. In example I use mail
item to set TO field. When in outlook Tools\Options\Mail Format\Use
Microsoft Office Word is NOT checked everything works ok. But when I
check this option and use MS Word as e-mail editor the sample code does
not work correctly. All assignment to "TO" field are reflected in
very first opened Word editor. It happened because "insp" parameter
points to the same object in all cases when OnNewInspector event was
fired (previously opened MS Word editors were not closed).

void __stdcall CCarbonOutClient::OnNewInspector(Outlook::_Inspector*
insp)
{

...

IDispatch* pCurrentItem;
CComPtr<Outlook::_MailItem> pMailItem;

insp->get_CurrentItem(&pCurrentItem);
HRESULT hr = pCurrentItem->QueryInterface(IID__MailItem,
(void**)&pMailItem);
...
pMailItem->TO = "Some Text";
}

How I can overcome this problem?
Is there any hot fix from Microsoft or some workaround?

Thanks,
Dennis.
 

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