Group:  Microsoft Outlook ยป microsoft.public.outlook.program_addins
Thread: Outlook add-in, MS Word problem

Geek News

Outlook add-in, MS Word problem
"Dennis Masko" <dmasko[ at ]lohika.lviv.ua> 2/21/2006 2:31:56 PM
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.

Re: Outlook add-in, MS Word problem
Jim <rog_21[ at ]yahoo.com> 2/21/2006 5:42:24 PM
What you may have to do Dennis is use an Inspector Wrapper to help with
your problem. Earlier Ken pointed me to an example in C#:
http://www.outlookcode.com/codedetail.aspx?id=797
Hope this helps

Dennis Masko wrote:
[Quoted Text]
> 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.
>

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net