Displaying custom form

M

Melbin

I made a custom form and published it following these steps,

1. Open a new mail message. On the Tools menu, click Forms and then click
Design This Form.
2. Click the (P.2) page of the form. On the Form menu, click Control
Toolbox. Use the Control Toolbox to add a Command Button to page P.2.
3. On the Tools menu, click Forms and then click Publish Form As. Select the
Inbox as the destination, enter MyForm as the Display Name, and then click
Publish. Choose either Yes or No when you are prompted about sending the form
definition with the item.
4. Close and don't save changes to the form.
5. On the Actions menu, click New MyForm.
6. Click the P.2 page of the form and click the button.

I verified this by clicking the Actions menu and saw New MyForm listed at
the bottom of the menu.

I am doing in vc++ 6.0 and using the Com dll.

// -------------showing the custom form---------------
_bstr_t bstrName_T (_T("MAPI"));
BSTR bstrName;
bstrName = bstrName_T.copy();
CComPtr <Outlook::_NameSpace> olNs;
m_spApp->GetNamespace(bstrName,&olNs);
CComQIPtr <Outlook::MAPIFolder> oInbox;
Outlook::OlDefaultFolders enumODF = olFolderInbox;
hr = olNs->GetDefaultFolder(enumODF,&oInbox);
CComQIPtr <Outlook::_Items> NewItems;
hr=oInbox->get_Items(&NewItems);
CComVariant nItem("IPM.Note.MyForm");
IDispatch* itm;
hr=NewItems->Add(nItem,&itm);
_NoteItem *pNoteItem = (_NoteItem *) itm;
CComVariant vEmpty(DISP_E_PARAMNOTFOUND, VT_ERROR);
hr=pNoteItem->Display(vEmpty);
//-------------------------------------------------------------

I use dthis in the NewInspector event but this is giving some Access
violation error in hr=pNoteItem->Display(vEmpty);
Anybody have any idea why is it so?Is this the correct way of doing?My idea
is to show the custom form instead of the default form.

Thanks a lotz in Advance
Melbin
 
M

Melbin

what i did earlier was wrong.i got the correct way of doing it.But then with
my custom form i am getting the default form also.That is default form will
be shown and the p.2 tab will be there.If i click that then the custom form
will be there in that tab.How to show only the custom form?

i did like,
I made a custom form and published it following these steps,

1. Open a new mail message. On the Tools menu, click Forms and then click
Design This Form.
2. Click the (P.2) page of the form. On the Form menu, click Control
Toolbox. Use the Control Toolbox to add a Command Button to page P.2.
3. On the Tools menu, click Forms and then click Publish Form As. Select
the Inbox as the destination, enter MyForm as the Display Name, and then
click Publish. Choose either Yes or No when you are prompted about sending
the form definition with the item.
4. Close and don't save changes to the form.
5. On the Actions menu, click New MyForm.
6. Click the P.2 page of the form and click the button.
I verified this by clicking the Actions menu and saw New MyForm listed at
the bottom of the menu.

I am doing in vc++ 6.0 and using the Com dll.I did this code in the
NewInspector event,

char str[100];
BSTR newMsgClass;
_bstr_t newMsgClass_T (_T("IPM.Note.MyForm "));
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=pMailItem->Display();

How to change this to get the desired result?
Thanks a lotz in Advance.
 
M

Melbin

I got it.


Melbin said:
what i did earlier was wrong.i got the correct way of doing it.But then with
my custom form i am getting the default form also.That is default form will
be shown and the p.2 tab will be there.If i click that then the custom form
will be there in that tab.How to show only the custom form?

i did like,
I made a custom form and published it following these steps,

1. Open a new mail message. On the Tools menu, click Forms and then click
Design This Form.
2. Click the (P.2) page of the form. On the Form menu, click Control
Toolbox. Use the Control Toolbox to add a Command Button to page P.2.
3. On the Tools menu, click Forms and then click Publish Form As. Select
the Inbox as the destination, enter MyForm as the Display Name, and then
click Publish. Choose either Yes or No when you are prompted about sending
the form definition with the item.
4. Close and don't save changes to the form.
5. On the Actions menu, click New MyForm.
6. Click the P.2 page of the form and click the button.
I verified this by clicking the Actions menu and saw New MyForm listed at
the bottom of the menu.

I am doing in vc++ 6.0 and using the Com dll.I did this code in the
NewInspector event,

char str[100];
BSTR newMsgClass;
_bstr_t newMsgClass_T (_T("IPM.Note.MyForm "));
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=pMailItem->Display();

How to change this to get the desired result?
Thanks a lotz in Advance.

Melbin said:
I made a custom form and published it following these steps,

1. Open a new mail message. On the Tools menu, click Forms and then click
Design This Form.
2. Click the (P.2) page of the form. On the Form menu, click Control
Toolbox. Use the Control Toolbox to add a Command Button to page P.2.
3. On the Tools menu, click Forms and then click Publish Form As. Select the
Inbox as the destination, enter MyForm as the Display Name, and then click
Publish. Choose either Yes or No when you are prompted about sending the form
definition with the item.
4. Close and don't save changes to the form.
5. On the Actions menu, click New MyForm.
6. Click the P.2 page of the form and click the button.

I verified this by clicking the Actions menu and saw New MyForm listed at
the bottom of the menu.

I am doing in vc++ 6.0 and using the Com dll.

// -------------showing the custom form---------------
_bstr_t bstrName_T (_T("MAPI"));
BSTR bstrName;
bstrName = bstrName_T.copy();
CComPtr <Outlook::_NameSpace> olNs;
m_spApp->GetNamespace(bstrName,&olNs);
CComQIPtr <Outlook::MAPIFolder> oInbox;
Outlook::OlDefaultFolders enumODF = olFolderInbox;
hr = olNs->GetDefaultFolder(enumODF,&oInbox);
CComQIPtr <Outlook::_Items> NewItems;
hr=oInbox->get_Items(&NewItems);
CComVariant nItem("IPM.Note.MyForm");
IDispatch* itm;
hr=NewItems->Add(nItem,&itm);
_NoteItem *pNoteItem = (_NoteItem *) itm;
CComVariant vEmpty(DISP_E_PARAMNOTFOUND, VT_ERROR);
hr=pNoteItem->Display(vEmpty);
//-------------------------------------------------------------

I use dthis in the NewInspector event but this is giving some Access
violation error in hr=pNoteItem->Display(vEmpty);
Anybody have any idea why is it so?Is this the correct way of doing?My idea
is to show the custom form instead of the default form.

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