Invoke custom Form Region from a click event

A

Ajay AKG

Hello,

I have created an Outlook 2007 custom form region of type IPM.Note in
outlook 2007 and imported it in a VS2008 outlook addin project. Now I would
like to programmatically invoke the custom form region in a mailitem
inspector. I am attempting to do this on the click event of a command bar
button.

Please help.

Regards
Ajay
 
K

Ken Slovak - [MVP - Outlook]

Invoke the form region in what way? You can get the form region when it
initializes and keep that reference, the only method that might be useful to
you is the Select() method, but that won't let you hide the region or make
it invisible or show it if it's not being shown.

Search on "form regions" at www.outlookcode.com for lots more information on
form regions.
 
A

Ajay AKG

Hi Ken,

Let me elaborate my problem.

I have created a custom form region in VS2008 using the form region wizard.
It is a "Replace All" form region with a custom message class
"IPM.Note.CustomFormRegion". I want this form region to display to the user
when the user clicks on a custom command button on the main windows toolbar.

This is the code I am using on the click event of the custom command button:

void menuItem1_Click(Office.CommandBarButton Ctrl, ref bool
CancelDefault)
{
Outlook.MailItem miItem =
(Outlook.MailItem)Application.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
miItem.GetInspector.Display(true);

}

The above code does display a Mail Item Inspector, but does not display my
custom form in this inspector. This is what I intend to do.

I am new to outlook programming. So, please help. A code sample to make this
happen would be useful.

Thanks and Regards
Ajay Ghadge
 
K

Ken Slovak - [MVP - Outlook]

Use the CreateItemFromTemplate() method to create your custom form or use
the Items.Add() method on the Items collection of the folder where you want
to add it. Use your custom MessageClass as an argument, otherwise a standard
IPM.Note item will be created.

I'm not sure, I haven't tried this and my gut tells me it won't work, but
you can test to see if once the item is created as a standard mail item you
change the MessageClass from "IPM.Note" to "IPM.Note.CustomFormRegion".
 
A

Ajay AKG

hi Ken,

I was able to solve it. Here's is the code snippet for the same. It is along
the same lines on what you have suggested. Thanks! for the pointer.

Outlook.Application myApp = new Outlook.ApplicationClass();

Outlook.NameSpace ns = myApp.GetNamespace("MAPI");
Outlook.MAPIFolder mapi =
ns.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderNotes);

Outlook.MailItem miItem =
(Outlook.MailItem)mapi.Items.Add("IPM.Note.Evidence");
miItem.Display(true);

Regards
Ajay Ghadge
 

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