none
VSTO: Open Outlook appointment item in custom form RRS feed

  • Question

  • I have created a separate form region to display outlook appointment fields (eg. Subject, Location, etc)

    my issue is when i double click on the outlook appointment item it always open in default view. How do I bind items to my customized form?

    selection change event works fine. Is there any similar way to create event handler in item open event to pop up my customized form.

    eg:

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

    currentExplorer = this.Application.ActiveExplorer(); Outlook.MAPIFolder olCalendarItems = (Outlook.MAPIFolder)Application.ActiveExplorer().Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar);

                currentExplorer.SelectionChange += new Outlook.ExplorerEvents_10_SelectionChangeEventHandler(CurrentExplorer_Event);

    olCalendarItems.open ??? }

    Thanks.


    Wednesday, September 3, 2014 11:29 PM

Answers

  • Did you try to use the Visible property to get the form region visible?

    If you need to get it visible by default you need to use the replacement layout with a custom message class. In that case the region will be displayed out of the box.

    Also you can handle the NewInspector/Activate event and set the message class you specified for the form region to display for:

    void inspectors_NewInspector(Microsoft.Office.Interop.Outlook.Inspector Inspector)
    {
       try
       {
          if (Inspector.CurrentItem is Outlook.TaskItem)
          {                    
              Outlook.TaskItem tItem = Inspector.CurrentItem as Outlook.TaskItem;
              if((tItem.Parent as Outlook.Folder).Name=="...")
                  tItem.MessageClass = "IPM.Task.ReplacementFormRegion";
           }
        }
        catch(Exception ex)
        {
            MessageBox.Show(ex.ToString());
        }
    }
    

    See the Outlook Form Regions forum thread for more information.

    Thursday, September 4, 2014 6:03 AM
  • The Open event allows to cancel the action and show your own form only, you just need to set the Cancel parameter to false.
    Friday, September 5, 2014 9:42 AM

All replies

  • Did you try to use the Visible property to get the form region visible?

    If you need to get it visible by default you need to use the replacement layout with a custom message class. In that case the region will be displayed out of the box.

    Also you can handle the NewInspector/Activate event and set the message class you specified for the form region to display for:

    void inspectors_NewInspector(Microsoft.Office.Interop.Outlook.Inspector Inspector)
    {
       try
       {
          if (Inspector.CurrentItem is Outlook.TaskItem)
          {                    
              Outlook.TaskItem tItem = Inspector.CurrentItem as Outlook.TaskItem;
              if((tItem.Parent as Outlook.Folder).Name=="...")
                  tItem.MessageClass = "IPM.Task.ReplacementFormRegion";
           }
        }
        catch(Exception ex)
        {
            MessageBox.Show(ex.ToString());
        }
    }
    

    See the Outlook Form Regions forum thread for more information.

    Thursday, September 4, 2014 6:03 AM
  • Thanks for the reply, I am new to vsto programming.

    I just add the Form Region from solution explorer, visual studio automatically open set it as default form region and also button added to the outlook toolbar. I haven't write any cording to display form region.

    I also found an alternative solution for this. Instead of formRegion I have created a separate form to populate fields.

                  Outlook.AppointmentItem apptItem = (selObject as Outlook.AppointmentItem); 
                   if (apptItem != null)  
                 
     			{   
                           if (apptItem.Categories == "MY_CATEGORY")  
                      {                        GlobalAPPID = apptItem.GlobalAppointmentID;    
                        apptItem.Open += new Microsoft.Office.Interop.Outlook.ItemEvents_10_OpenEventHandler(mcAI_Open);   
                     }                         
    		  }

    private void mcAI_Open(ref bool Cancel) { Form1 frm = new Form1();

    frm.Show(); }



    • Edited by Chan12 Friday, September 5, 2014 3:43 AM
    Friday, September 5, 2014 2:40 AM
  • The Open event allows to cancel the action and show your own form only, you just need to set the Cancel parameter to false.
    Friday, September 5, 2014 9:42 AM
  • If you want to apply your form region in the VSTO add-in, here are 2 links you can refer to.

    Walkthrough: Creating an Outlook Form Region

    Creating Outlook 2007 Form Regions using Visual Studio Tools for the Office System (3.0)

    • Proposed as answer by chunchencool Wednesday, September 10, 2014 7:10 AM
    Wednesday, September 10, 2014 7:10 AM