none
Which Outlook Form Region type should I go for? RRS feed

  • Question

  • Hi all,

    What type of Outlook form region would I use if I wanted a seperate form that does not disturb any inbuilt/default functionality?

    I do not want it to append to any default form. Nor do I want it to replace something or everything in a default form. I want it to be seperate. It would be invoked on the click on a button on my custom tab from the Outlook explorer ribbon.

    Edit: I realize that I need a seperate form altogether and not a 'region' of an existing form. So, how would I go about adding my own custom type of form?


    Thanks Prashanth



    Monday, June 11, 2012 1:29 PM

Answers

  • It's always going to have that "- Appointment" unless you use the Win32 API to set the window caption. It could be done, but I'm not sure it would necessarily be a wise idea.
     
    You would get the hWnd of the window and use SetWindowText() to set the new caption. Inspectors now implement the IWin32Window interface so it's pretty easy to get the hWnd of the Inspector.
     
    As far as a substitute form, it could be any type of form you want to design. You'd put textboxes, dropdowns, labels, grids or whatever your heart desired on the form. You'd then get the control values when the user clicked OK and add them to an Appointment item or whatever. So if you had calendar controls there for start time and end time you'd set those values on the Appointment item from whatever was set on your form, and so on.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "Prashanth Iyer" <=?utf-8?B?UHJhc2hhbnRoIEl5ZXI=?=> wrote in message news:16002dc2-a906-4890-92a9-df4d5819450d...

    Okay, I just figured out the first part,

      // Creating an inspector object to call the SetCurrentFormPage method.           
                Outlook.Inspector appointmentItem = oMsg.GetInspector;
                // Hides the Appointment form
                appointmentItem.HideFormPage("Appointment");
                // Displaying the Create SR form.
                appointmentItem.SetCurrentFormPage("ServiceRequestAddin.formCreateSR");            
                appointmentItem.Display();

    Why can't we change the name of the Appointment tab? Is it possible to get the handle of the current ribbon and then change the name of the tab from there? We want to change it only for this instance after all.

    Plus, I did change the Subject to "New XYZ" , but it still shows "New XYZ - Appointment"  :|

    Can I do something about it?

    Thanks



    Ken Slovak MVP - Outlook
    Tuesday, June 12, 2012 3:52 PM
    Moderator

All replies

  • if you do not want to add it to any default message classes and want to show/hide it by clicking button in explorer then maybe custom task pane would be a better option? You can create form region that 'inherits' from one of default ones and add your content as a separate tab, but it will not work with show/hide button from explorer window.

    Monday, June 11, 2012 1:32 PM
  • Sorry, I didn't quite get that. I do not have any show/hide button in explorer.

    My current code on clicking button is like this:

     private void btnCreateSR_Click(object sender, RibbonControlEventArgs e)
            {
                // Getting the handle of outlook and storing it in the currentOutlook object.
                Outlook.Application currentOutlook = Globals.ThisAddIn.Application;
                // Creating a new appointment item and storing the handle in oMsg object.            
                Outlook.AppointmentItem oMsg = (Outlook.AppointmentItem)currentOutlook.CreateItem(Outlook.OlItemType.olAppointmentItem);    
                
                // Displaying the oMsg item, so that the user can see the create SR form. 
                oMsg.Display();
                // Creating an inspector object to call the SetCurrentFormPage method.           
                Outlook.Inspector appointmentItem = currentOutlook.ActiveInspector();
                // Hides the Appointment form
                appointmentItem.HideFormPage("Appointment");
                       
                // Displaying the Custom form .
                appointmentItem.SetCurrentFormPage("ServiceRequestAddin.customForm");
               
            }

    This shows my custom form. But it still shows the appointment form for a second before hiding it and switching to my custom form. Plus, the window says "Untitiled - Appointment" and the tab says "Appointment" as well. I want all this to be customized. And I want to do it before we display the form to the user.


    Thanks Prashanth

    Monday, June 11, 2012 1:46 PM
  • You can set a subject for the item before you show it, that will prevent the "Untitled" caption. You cannot change the name of the Appointment tab. You can make the desired tab the current tab before you show the item.
     
    If you want something more than that you could just create a custom Windows Form or other form type. Display that and grab whatever values from that form that you want and put them into an Outlook item.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "Prashanth Iyer" <=?utf-8?B?UHJhc2hhbnRoIEl5ZXI=?=> wrote in message news:fa53548e-ee63-4420-b615-c1d5607c8b16...

    Sorry, I didn't quite get that. I do not have any show/hide button in explorer.

    My current code on clicking button is like this:

     private void btnCreateSR_Click(object sender, RibbonControlEventArgs e)
            {
                // Getting the handle of outlook and storing it in the currentOutlook object.
                Outlook.Application currentOutlook = Globals.ThisAddIn.Application;
                // Creating a new appointment item and storing the handle in oMsg object.            
                Outlook.AppointmentItem oMsg = (Outlook.AppointmentItem)currentOutlook.CreateItem(Outlook.OlItemType.olAppointmentItem);    
                
                // Displaying the oMsg item, so that the user can see the create SR form. 
                oMsg.Display();
                // Creating an inspector object to call the SetCurrentFormPage method.           
                Outlook.Inspector appointmentItem = currentOutlook.ActiveInspector();
                // Hides the Appointment form
                appointmentItem.HideFormPage("Appointment");
                       
                // Displaying the Custom form .
                appointmentItem.SetCurrentFormPage("ServiceRequestAddin.customForm");
               
            }

    This shows my custom form. But it still shows the appointment form for a second before hiding it and switching to my custom form. Plus, the window says "Untitiled - Appointment" and the tab says "Appointment" as well. I want all this to be customized. And I want to do it before we display the form to the user.


    Thanks Prashanth


    Ken Slovak MVP - Outlook
    Monday, June 11, 2012 2:52 PM
    Moderator
  • You can set a subject for the item before you show it, that will prevent the "Untitled" caption. You cannot change the name of the Appointment tab. You can make the desired tab the current tab before you show the item.
    If you want something more than that you could just create a custom Windows Form or other form type. Display that and grab whatever values from that form that you want and put them into an Outlook item.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    Ken Slovak MVP - Outlook

    Hi Ken,

    Thank you for your reply. About the first part, I am currently doing this :

    private void btnCreateSR_Click(object sender, RibbonControlEventArgs e)
            {
                // Getting the handle of outlook and storing it in the currentOutlook object.
                Outlook.Application currentOutlook = Globals.ThisAddIn.Application;
                // Creating a new appointment item and storing the handle in oMsg object.            
                Outlook.AppointmentItem oMsg = (Outlook.AppointmentItem)currentOutlook.CreateItem(Outlook.OlItemType.olAppointmentItem);
                
                // Displaying the oMsg item, so that the user can see the create SR form. 
                oMsg.Display();
                // Creating an inspector object to call the SetCurrentFormPage method.           
                Outlook.Inspector appointmentItem = currentOutlook.ActiveInspector();
                // Hides the Appointment form
                appointmentItem.HideFormPage("Appointment");
                // Displaying the Create SR form.
                appointmentItem.SetCurrentFormPage("ServiceRequestAddin.formCreateSR");
            }

    How do I make the desired tab the selected tab BEFORE showing? I need inspectorObject.SetcurrentFormPage and I cannot delcare the inspectorObject unless the appointmentItem.Display() is called. It gives me a NullPointerException.

    Can you please elaborate on the second part? "create a custom Windows Form or other form type"

    Thanks a bunch!


    Thanks Prashanth

    Tuesday, June 12, 2012 6:05 AM
  • Okay, I just figured out the first part,

      // Creating an inspector object to call the SetCurrentFormPage method.           
                Outlook.Inspector appointmentItem = oMsg.GetInspector;
                // Hides the Appointment form
                appointmentItem.HideFormPage("Appointment");
                // Displaying the Create SR form.
                appointmentItem.SetCurrentFormPage("ServiceRequestAddin.formCreateSR");            
                appointmentItem.Display();

    Why can't we change the name of the Appointment tab? Is it possible to get the handle of the current ribbon and then change the name of the tab from there? We want to change it only for this instance after all.

    Plus, I did change the Subject to "New XYZ" , but it still shows "New XYZ - Appointment"  :|

    Can I do something about it?

    Thanks


    Tuesday, June 12, 2012 6:38 AM
  • i;m afraid that only using Windows API you will be able to set title of window. As for changing name of appointmnet tab - title in window is not taken from the name of the tab, rather from user friendly name of message class of item shown.
    Tuesday, June 12, 2012 7:37 AM
  • It's always going to have that "- Appointment" unless you use the Win32 API to set the window caption. It could be done, but I'm not sure it would necessarily be a wise idea.
     
    You would get the hWnd of the window and use SetWindowText() to set the new caption. Inspectors now implement the IWin32Window interface so it's pretty easy to get the hWnd of the Inspector.
     
    As far as a substitute form, it could be any type of form you want to design. You'd put textboxes, dropdowns, labels, grids or whatever your heart desired on the form. You'd then get the control values when the user clicked OK and add them to an Appointment item or whatever. So if you had calendar controls there for start time and end time you'd set those values on the Appointment item from whatever was set on your form, and so on.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "Prashanth Iyer" <=?utf-8?B?UHJhc2hhbnRoIEl5ZXI=?=> wrote in message news:16002dc2-a906-4890-92a9-df4d5819450d...

    Okay, I just figured out the first part,

      // Creating an inspector object to call the SetCurrentFormPage method.           
                Outlook.Inspector appointmentItem = oMsg.GetInspector;
                // Hides the Appointment form
                appointmentItem.HideFormPage("Appointment");
                // Displaying the Create SR form.
                appointmentItem.SetCurrentFormPage("ServiceRequestAddin.formCreateSR");            
                appointmentItem.Display();

    Why can't we change the name of the Appointment tab? Is it possible to get the handle of the current ribbon and then change the name of the tab from there? We want to change it only for this instance after all.

    Plus, I did change the Subject to "New XYZ" , but it still shows "New XYZ - Appointment"  :|

    Can I do something about it?

    Thanks



    Ken Slovak MVP - Outlook
    Tuesday, June 12, 2012 3:52 PM
    Moderator
  • As far as a substitute form, it could be any type of form you want to design. You'd put textboxes, dropdowns, labels, grids or whatever your heart desired on the form. You'd then get the control values when the user clicked OK and add them to an Appointment item or whatever. So if you had calendar controls there for start time and end time you'd set those values on the Appointment item from whatever was set on your form, and so on.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007

    Hey Ken, thanks again!

    Just to be clear..for the subtistute form, Should I add a new windows forms project to my solution or a new Outlook form region to my Outlook add in project?

    Because, right now, I am doing the latter. I have :

    1. Added a form region to my appointment inspector

    2. Hidden the appointment form

    3. Displayed my custom form

    4. Picked up values from there and dropped it off in the appointment.

    The only thing thats left is to customize the tab that says "Appointment" . So, as I cannot rename it, is it possible to:

    1. Hide the appointment tab

    2. Select my custom tab

    3. Then show to the user?

    Regards,

    Prashanth


    Thanks Prashanth



    Wednesday, June 13, 2012 5:45 AM
  • By the way, I can't use Win32 API because FindWindow would need the window to be displayed before it can find it..

    Thanks Prashanth

    Wednesday, June 13, 2012 10:52 AM
  • You wouldn't need FindWindow(), even hidden windows have hWnd's.
     
    Take a look at the code at http://flakerman.blogspot.com/2008/10/getting-window-handle-hwnd-for-outlook.html. It uses a QI on the Inspector object to get the Inspector window handle, it's the type of thing I was thinking about.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "Prashanth Iyer" <=?utf-8?B?UHJhc2hhbnRoIEl5ZXI=?=> wrote in message news:dcdc142c-6695-46dd-8877-f3714c463637...
    By the way, I can't use Win32 API because FindWindow would need the window to be displayed before it can find it..

    Thanks Prashanth


    Ken Slovak MVP - Outlook
    Wednesday, June 13, 2012 3:24 PM
    Moderator
  • I don't think you'll be able to hide the default Appointment tab, but try it. That's how you learn :)
     
    If I wanted to do that and use a form region I'd use a replacement region probably.
     
    Using a form of your own design, whether Windows.Forms or WCF or whatever allows you to design it as you please and then read any control settings made on your form into the properties of an Outlook item.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "Prashanth Iyer" <=?utf-8?B?UHJhc2hhbnRoIEl5ZXI=?=> wrote in message news:c150c543-ca53-493e-9934-07f89630b3d4...
    As far as a substitute form, it could be any type of form you want to design. You'd put textboxes, dropdowns, labels, grids or whatever your heart desired on the form. You'd then get the control values when the user clicked OK and add them to an Appointment item or whatever. So if you had calendar controls there for start time and end time you'd set those values on the Appointment item from whatever was set on your form, and so on.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007

    Hey Ken, thanks again!

    Just to be clear..for the subtistute form, Should I add a new windows forms project to my solution or a new Outlook form region to my Outlook add in project?

    Because, right now, I am doing the latter. I have :

    1. Added a form region to my appointment inspector

    2. Hidden the appointment form

    3. Displayed my custom form

    4. Picked up values from there and dropped it off in the appointment.

    The only thing thats left is to customize the tab that says "Appointment" . So, as I cannot rename it, is it possible to:

    1. Hide the appointment tab

    2. Select my custom tab

    3. Then show to the user?

    Regards,

    Prashanth


    Thanks Prashanth




    Ken Slovak MVP - Outlook
    Wednesday, June 13, 2012 3:24 PM
    Moderator