New Inspector word editor crash Outlook 2003

T

Tom

Hi all,

I have a rather interesting issue with Outlook 2003. When a create a new
email message using automation outlook will crash if I try to request the
word editor(GetWordEditor) during the new inspector event.

***************************************
My settings
***************************************
1. I have Word selected as my default HTML editor. So every new message
uses word.
2. Every thing works perfect when I create a new message using Outlook menu
or new message button. (No Issues at all)

Here is the scenario the breaks.

***************************************
From button command in main window
***************************************
CComPtr<IDispatch> spDisp;
HRESULT hr = m_spApplication->raw_CreateItem(Outlook::eek:lMailItem, &spDisp);

if(SUCCEEDED(hr) && spDisp)
{
CComPtr<Outlook::_MailItem> spMailItem;
hr = spDisp->QueryInterface(__uuidof(Outlook::_MailItem),
(LPVOID*)&spMailItem);
if(SUCCEEDED(hr) && spMailItem)
{
spMailItem->PutBodyFormat(Outlook::eek:lFormatHTML);

// This will generate the "new" inspector event.
spMailItem->Display(_variant_t(true));
}
}

***************************************
In the new inspector
***************************************
if(m_spInspector->GetEditorType() == Outlook::eek:lEditorWord)
m_bEditorIsWord = TRUE;

if(m_bEditorIsWord)
{
KABOOOOOM !!!!<<<<<<<<<<<<

KABOOOOOM !!!! The dispatch pointer is NULL!!! Uhg!!!!
}


IF I comment out the faulty lines of code -- surprisingly --- the new
message will invoke the HTML editor and NOT the word editor. STRANGE!! This
happens on every machine I have tested this on.

Has anybody run into this issue?

Thanks,
Tom -
 
T

Tom

More info ....

I switched the email editor to HTML only and it still fails. It appears to
me that the inspector is returning a bad value for GetEditorType()
 
T

Tom

Never mind - I found an error in my code

Tom said:
More info ....

I switched the email editor to HTML only and it still fails. It appears to
me that the inspector is returning a bad value for GetEditorType()
 
K

Ken Slovak - [MVP - Outlook]

FWIW, when NewInspector() fires you get what are called weak object
references for the Inspector and for the Inspector.CurrentItem. This is a
worst case with WordMail and with Outlook 2007 or later. My rule of thumb is
to only check for Inspector.CurrentItem.Class or CurrentItem.MessageClass in
that event and to defer anything else to the first Inspector.Activate()
event handler on the Inspector. By that time the object references are
strong and fully fleshed out.
 

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