opening new mail message form

G

Guest

I have created my custom Message form. Now I want display my new custom form
when a user open an existing Mail Message. I've write this code that caugth
new
inspector event:
void __stdcall CSampleAddin::NewInspector(IDispatch* pdispInspector)
{
_Inspector *pInsp = (_Inspector *)pdispInspector;
IDispatch *pCurrentItem;
hr=pInsp->get_CurrentItem(&pCurrentItem);
_MailItem *pMailItem = (_MailItem *) pCurrentItem;
BSTR newMsgClass,oldMsgClass;
_bstr_t newMsgClass_T (_T("IPM.Note.sampleform"));
newMsgClass = newMsgClass_T.copy();
hr=pMailItem->put_MessageClass(newMsgClass);
hr=pMailItem->Save();
CComPtr <Outlook::_MailItem> NewMailItem;
hr=pMailItem->Copy((IDispatch**)&NewMailItem);
hr=NewMailItem->Save();
hr=pMailItem->Delete();
hr=NewMailItem->Display();

}

I noticed that if I don't follow this way, i.e. modify Message Class of item
with default form, copy this item in a new item with My custom form, Save
this new contact item and then delete old current item
BUT
if I only change the Message Class of current item, Outlook doesn't displays
correctly the form (displays always the default form) .

Now, with the above code when I double click on a mail message, outlook
displays two forms: one default form and one My custom form. Why is that?

I tried to use hr=pInsp->Close(olDiscard); and hr=pMailItem->Close(olDiscard);
but then also i'm getting both the forms.

Thanks a lotz in Advance,
Melbin
 

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