Solved

Can't display custom property page in Outlook 2007

Posted on 2010-11-09
1
528 Views
Last Modified: 2012-05-10
I've followed a tutorial within a book that was written for Visual Studio 2005. Given the tutorial I can't get the new proprty page to open up in Outlook's Tools > Options page. What is wrong with the sample code?
//ThisAddIn.cs
using System;
using System.Windows.Forms;
using Microsoft.VisualStudio.Tools.Applications.Runtime;
using Outlook = Microsoft.Office.Interop.Outlook;

namespace TestPropertyPage
{
    public partial class ThisAddIn
    {
        private void ThisAddIn_Startup(object sender, EventArgs e)
        {
            //Create the Options Page
            System.Windows.Forms.Application.EnableVisualStyles();
            Application.OptionsPagesAdd += new Outlook.ApplicationEvents_11_OptionsPagesAddEventHandler(ThisAddIn_OptionsPagesAdd);
        }

        private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
        {
        }

        private void ThisAddIn_OptionsPagesAdd(Outlook.PropertyPages pages)
        {
            pages.Add(new OptionPage(), "");
        }
        #region VSTO generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InternalStartup()
        {
            this.Startup += new System.EventHandler(ThisAddIn_Startup);
            this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
        }
        
        #endregion
    }
}


//OptionPage.cs
using System;
using System.Windows.Forms;
using Outlook = Microsoft.Office.Interop.Outlook;
using System.Runtime.InteropServices;

namespace TestPropertyPage
{
    public partial class OptionPage : UserControl, Outlook.PropertyPage
    {
        const int captionDispID = -518;
        bool isDirty = false;
        
        public OptionPage()
        {
            InitializeComponent();
        }

        void Outlook.PropertyPage.Apply()
        {
            MessageBox.Show("The user clicked the apply button.");
        }

        bool Outlook.PropertyPage.Dirty
        {
            get
            {
                return isDirty;
            }
        }

        void Outlook.PropertyPage.GetPageInfo(ref string helpFile, ref int helpContext)
        {
        }

        [DispId(captionDispID)]
        public string PageCaption
        {
            get
            {
                return "Test Property Page";
            }
        }
    }
}

Open in new window

0
Comment
Question by:Chris_Rennie
1 Comment
 

Accepted Solution

by:
Chris_Rennie earned 0 total points
ID: 34140108
Before declaring the OptionPage class, it needed:

[ComVisible(true)]

Then the custom Option Page displayed as intended.
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question