T
Tony Feldmesser
Hi All,
I am trying to programmatically create a custom page inside the contact
inspector of outlook 2003 using an add-in created with Visual C# 2003 and
Visual Studio Tools for Office 2003. I have a simple add-in that places a
button on a command bar, and clicking that button executes the code below. I
do see the new page "Test" in the inspector, but the last line before the
catch, "myPage = (Page) obj;", throws an invalid cast exception. So if the
new object is not a 'Page', then what is it? I get the same error if I try
to get the page with "myPage = (Page) myPages["Test"];". Any suggestions
would be welcome!
Regards,
Tony
~~~~~
try
{
ContactItem myContact;
Inspector myInspector;
Outlook.Pages myPages;
Page myPage;
myContact = (ContactItem) outlookApp.CreateItem(
Outlook.OlItemType.olContactItem);
myContact.FullName = "Test Contact";
myInspector = myContact.GetInspector;
myPages = (Outlook.Pages) myInspector.ModifiedFormPages;
object obj = myPages.Add("Test");
myInspector.ShowFormPage("Test");
myContact.Display(false);
myPage = (Page) obj; // <<< this fails
// do stuff with the page here ...
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message);
}
I am trying to programmatically create a custom page inside the contact
inspector of outlook 2003 using an add-in created with Visual C# 2003 and
Visual Studio Tools for Office 2003. I have a simple add-in that places a
button on a command bar, and clicking that button executes the code below. I
do see the new page "Test" in the inspector, but the last line before the
catch, "myPage = (Page) obj;", throws an invalid cast exception. So if the
new object is not a 'Page', then what is it? I get the same error if I try
to get the page with "myPage = (Page) myPages["Test"];". Any suggestions
would be welcome!
Regards,
Tony
~~~~~
try
{
ContactItem myContact;
Inspector myInspector;
Outlook.Pages myPages;
Page myPage;
myContact = (ContactItem) outlookApp.CreateItem(
Outlook.OlItemType.olContactItem);
myContact.FullName = "Test Contact";
myInspector = myContact.GetInspector;
myPages = (Outlook.Pages) myInspector.ModifiedFormPages;
object obj = myPages.Add("Test");
myInspector.ShowFormPage("Test");
myContact.Display(false);
myPage = (Page) obj; // <<< this fails
// do stuff with the page here ...
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message);
}