opening new custom Message form

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
Thanks a lotz in Advance,
Melbin
The two premier sites for all things Outlook and Exchange, go to
www.outlook-code.com and www.slipstick.com. Solutions to a lot of your
tasks can be found there, before you write code. Specifically, go to
www.outlook-code.com and search on "default form", without the quotes,
and you will find a page that tells you how to create a new default
form and how to switch all your old items to the new form. The
utilities to do this have existed almost as long as Outlook.

Hollis D. Paul [MVP - Outlook]
Mukilteo, WA USA
 
I got it.
Thanks a lotz for all your help.


Hollis D. Paul said:
Thanks a lotz in Advance,
Melbin
The two premier sites for all things Outlook and Exchange, go to
www.outlook-code.com and www.slipstick.com. Solutions to a lot of your
tasks can be found there, before you write code. Specifically, go to
www.outlook-code.com and search on "default form", without the quotes,
and you will find a page that tells you how to create a new default
form and how to switch all your old items to the new form. The
utilities to do this have existed almost as long as Outlook.

Hollis D. Paul [MVP - Outlook]
Mukilteo, WA USA
 
Back
Top