none
Outlook 2010: Create a new Appointment type? RRS feed

  • Question

  • I would like to be able to create a new appointment type that can be selected from the ribbon menu, like the meeting and appointment choices (so that the chioces are New Meeting, New Appointment and then New XXXXX), is this possible?

    The reason is that it is a type of appointment that also needs some separate fields. I think it will be fine to use form regions to just extend the default appointment form, but I don't want these extra field and behaviour (like sending out e-mails based on values in extra fields) to be implemented in the normal appointments. This new kind of appointment will be booked to a room only, and in extra fields there will be information about the appointment and one field for who the appointment is assigned to, and one field that will have customer e-mail address. Then it will send some custom information to the assigned person and the customer.

    But normal kind of appointments should still be able to be made, since this kind of appointment is a special appointment between a certain type of customer and an assigned person.

    Am I right in thinking a separate appointment type would be a good solution, or does anyone have a better way of solving this problem?

    Thursday, August 4, 2011 8:51 AM

Answers

  • It sounds like you need to handle the NewInspector() event of the Inspectors collection. That will fire when a new item is opened, including a new meeting request. In that handler set up an externally declared Inspector object and set up to handle its Activate() event. Make sure the Inspector object is declared at a scope where it won't be garbage collected, such as global or class scope.
     
    In that NewInspector() event handler check Inspector.CurrentItem.Class or MessageClass to verify it's a meeting request item. If it is set up the Activate() handler. In the Activate() handler you can then set the MessageClass to your custom class.
     
    See if that helps.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Jimmy-san" <=?utf-8?B?SmltbXktc2Fu?=> wrote in message news:7b978d4b-2584-4d06-bc64-f0f574564a24...

    Now that you mention it, no it doesn't. It just became null when casting it to Folder. I guess it just default to my own calendar and that's why it seemed to work when adding the meeting to my own calendar?

    If I keep it as MAPIFolder it does show all the correct values if I select my own calendar. But when selecting the meeting room calendar it shows some weird values. Like long binary for folder path and error on "Folders" because it can't find any object. Not sure how it's supposed to look. Still doesn't work to add an item to that calendar. When debugging it just stops/breaks out of the function at this line:
    Outlook.AppointmentItem appt = folder.Items.Add(@"IPM.Appointment.Visit") as Outlook.AppointmentItem;
    Whatever item (and message class) I try to add it just ignore it.

    I can't find how I'm supposed to add a meeting to a meeting room calendar by code. Is it possible to see the code that triggers when clicking on the "New Meeting" button in the ribbon? Since that one does exactly what I want, it's just that it is not set to my custom message class. If I call that button command through the commandbar (findcontrol by executing button with ID 1745) with my own button, is it possible to somehow inject another message class before it opens the window? That way I could make it show my form region.

    I basically just need to simulate the meeting button and give it "IPM.Appointment.Visit" as message class so it shows a form region for it.




    Ken Slovak MVP - Outlook
    • Marked as answer by Jimmy-san Tuesday, August 9, 2011 8:37 AM
    Friday, August 5, 2011 3:45 PM

All replies

  • Just set up your form region to only work with a custom MessageClass, such as "IPM.Appointment.MyCustomType" (or whatever you want to name it).
     
    Then create a ribbon button to open that type of item.
     
    To do that the code could either just open a new appointment item as usual and then set the MessageClass to your custom class, or you can use the Items.Add() method on the Items collection of the current folder. That method allows you to specify a custom MessageClass.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Jimmy-san" <=?utf-8?B?SmltbXktc2Fu?=> wrote in message news:4a2d0db9-50cc-4e63-bae1-cd019efe2457...

    I would like to be able to create a new appointment type that can be selected from the ribbon menu, like the meeting and appointment choices (so that the chioces are New Meeting, New Appointment and then New XXXXX), is this possible?

    The reason is that it is a type of appointment that also needs some separate fields. I think it will be fine to use form regions to just extend the default appointment form, but I don't want these extra field and behaviour (like sending out e-mails based on values in extra fields) to be implemented in the normal appointments. This new kind of appointment will be booked to a room only, and in extra fields there will be information about the appointment and one field for who the appointment is assigned to, and one field that will have customer e-mail address. Then it will send some custom information to the assigned person and the customer.

    But normal kind of appointments should still be able to be made, since this kind of appointment is a special appointment between a certain type of customer and an assigned person.

    Am I right in thinking a separate appointment type would be a good solution, or does anyone have a better way of solving this problem?


    Ken Slovak MVP - Outlook
    Thursday, August 4, 2011 1:09 PM
  • Thanks for the answer.

    Your answer helped a lot, but I'm having some problems still. The scenario is that the user selects a date on one of the Room Calendars and then click this new button. Then the custom meeting view is shown with the correct date and will be assigned to that calendar when they save it.

    But I'm not sure how I can create this new meeting on selected date. I have read an earlier thread about a work around to get the selected date, which involves opening and closing an appointment by calling the commandbar function for an appointment. I guess this work around is OK, but it flashes the window which isn't very easy on the eyes. But then when I create my new meeting, I also need to know what calendar it should be created in (the calendar they have selected the date in), but I can't seem to figure out how to get it.

    Is that work around (http://www.outlookcode.com/codedetail.aspx?id=616) the only way for me to add this custom appointment to the selected date on the selected calendar? If so, how can I save out the selected calendar to a variable so I can create the new meeting in the correct place?

    Edit:

    OK, I think I found out how to do it by using CalendarView.SelectedStartTime. However, the Room Calendar only accepts meetings and not appointments. So if I select a date on my own calendar, the button works and shows the meeting window. However, selecting a date on the Room calendar and pressing the button - nothing happens. This also happened when I used the work around fix trying to run the commandbar button for Appointment, because the Room calendar only accepts meetings. What exactly is the difference between those buttons that makes the calendar accept the meeting (which, unless I'm missing something, is an appointment but with OlMeetingStatus.olMeeting.

    Any idea how my created appointment can be made so that the Room calendar accepts it? I have added the OlMeetingStatus.olMeeting to it, but it doesn't seem to matter.

    Here is the code I use for testing, runs when pressing the button in the ribbon:

    DateTime dateNull = new DateTime(4501, 1, 1, 0, 0, 0);
    Outlook.View view = objExpl.CurrentView as Outlook.View;
    Outlook.Folder folder = objExpl.CurrentFolder as Outlook.Folder;
    
    if (view.ViewType == Outlook.OlViewType.olCalendarView)
    {
      Outlook.CalendarView calView = view as Outlook.CalendarView;
      DateTime dateStart = calView.SelectedStartTime;
      DateTime dateEnd = calView.SelectedEndTime;
      Outlook.AppointmentItem appt = folder.Items.Add(@"IPM.Appointment.Visit") as Outlook.AppointmentItem;
      appt.MeetingStatus = Outlook.OlMeetingStatus.olMeeting;
    
      if (dateStart != dateNull && dateEnd != dateNull)
      {
         appt.Start = dateStart;
         appt.End = dateEnd;
       }
       appt.Display(false);
    } 

     

    • Edited by Jimmy-san Friday, August 5, 2011 11:27 AM New information
    Friday, August 5, 2011 10:01 AM
  • Yes, that code is still probably the best workaround.
     
    If the calendar folder is selected in the current Explorer view, does ActiveExplorer().CurrentFolder work for what you need to determine the currently selected calendar folder?

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Jimmy-san" <=?utf-8?B?SmltbXktc2Fu?=> wrote in message news:e08e22f6-cf19-437e-9b87-c6fa9c7dd6bc...

    Thanks for the answer.

    Your answer helped a lot, but I'm having some problems still. The scenario is that the user selects a date on one of the Room Calendars and then click this new button. Then the custom meeting view is shown with the correct date and will be assigned to that calendar when they save it.

    But I'm not sure how I can create this new meeting on selected date. I have read an earlier thread about a work around to get the selected date, which involves opening and closing an appointment by calling the commandbar function for an appointment. I guess this work around is OK, but it flashes the window which isn't very easy on the eyes. But then when I create my new meeting, I also need to know what calendar it should be created in (the calendar they have selected the date in), but I can't seem to figure out how to get it.

    Is that work around (http://www.outlookcode.com/codedetail.aspx?id=616) the only way for me to add this custom appointment to the selected date on the selected calendar? If so, how can I save out the selected calendar to a variable so I can create the new meeting in the correct place?

    Edit:

    OK, I think I found out how to do it by using CalendarView.SelectedStartTime. However, the Room Calendar only accepts meetings and not appointments. So if I select a date on my own calendar, the button works and shows the meeting window. However, selecting a date on the Room calendar and pressing the button - nothing happens. This also happened when I used the work around fix trying to run the commandbar button for Appointment, because the Room calendar only accepts meetings. What exactly is the difference between those buttons that makes the calendar accept the meeting (which, unless I'm missing something, is an appointment but with OlMeetingStatus.olMeeting.

    Any idea how my created appointment can be made so that the Room calendar accepts it? I have added the OlMeetingStatus.olMeeting to it, but it doesn't seem to matter.

    Here is the code I use for testing, runs when pressing the button in the ribbon:

    DateTime dateNull = new DateTime(4501, 1, 1, 0, 0, 0);
    Outlook.View view = objExpl.CurrentView as Outlook.View;
    Outlook.Folder folder = objExpl.CurrentFolder as Outlook.Folder;
    
    if (view.ViewType == Outlook.OlViewType.olCalendarView)
    {
     Outlook.CalendarView calView = view as Outlook.CalendarView;
     DateTime dateStart = calView.SelectedStartTime;
     DateTime dateEnd = calView.SelectedEndTime;
     Outlook.AppointmentItem appt = folder.Items.Add(@"IPM.Appointment.Visit") as Outlook.AppointmentItem;
     appt.MeetingStatus = Outlook.OlMeetingStatus.olMeeting;
    
     if (dateStart != dateNull && dateEnd != dateNull)
     {
       appt.Start = dateStart;
       appt.End = dateEnd;
      }
      appt.Display(false);
    } 

     


    Ken Slovak MVP - Outlook
    Friday, August 5, 2011 1:23 PM
  • Now that you mention it, no it doesn't. It just became null when casting it to Folder. I guess it just default to my own calendar and that's why it seemed to work when adding the meeting to my own calendar?

    If I keep it as MAPIFolder it does show all the correct values if I select my own calendar. But when selecting the meeting room calendar it shows some weird values. Like long binary for folder path and error on "Folders" because it can't find any object. Not sure how it's supposed to look. Still doesn't work to add an item to that calendar. When debugging it just stops/breaks out of the function at this line:
    Outlook.AppointmentItem appt = folder.Items.Add(@"IPM.Appointment.Visit") as Outlook.AppointmentItem;
    Whatever item (and message class) I try to add it just ignore it.

    I can't find how I'm supposed to add a meeting to a meeting room calendar by code. Is it possible to see the code that triggers when clicking on the "New Meeting" button in the ribbon? Since that one does exactly what I want, it's just that it is not set to my custom message class. If I call that button command through the commandbar (findcontrol by executing button with ID 1745) with my own button, is it possible to somehow inject another message class before it opens the window? That way I could make it show my form region.

    I basically just need to simulate the meeting button and give it "IPM.Appointment.Visit" as message class so it shows a form region for it.



    Friday, August 5, 2011 2:44 PM
  • It sounds like you need to handle the NewInspector() event of the Inspectors collection. That will fire when a new item is opened, including a new meeting request. In that handler set up an externally declared Inspector object and set up to handle its Activate() event. Make sure the Inspector object is declared at a scope where it won't be garbage collected, such as global or class scope.
     
    In that NewInspector() event handler check Inspector.CurrentItem.Class or MessageClass to verify it's a meeting request item. If it is set up the Activate() handler. In the Activate() handler you can then set the MessageClass to your custom class.
     
    See if that helps.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Jimmy-san" <=?utf-8?B?SmltbXktc2Fu?=> wrote in message news:7b978d4b-2584-4d06-bc64-f0f574564a24...

    Now that you mention it, no it doesn't. It just became null when casting it to Folder. I guess it just default to my own calendar and that's why it seemed to work when adding the meeting to my own calendar?

    If I keep it as MAPIFolder it does show all the correct values if I select my own calendar. But when selecting the meeting room calendar it shows some weird values. Like long binary for folder path and error on "Folders" because it can't find any object. Not sure how it's supposed to look. Still doesn't work to add an item to that calendar. When debugging it just stops/breaks out of the function at this line:
    Outlook.AppointmentItem appt = folder.Items.Add(@"IPM.Appointment.Visit") as Outlook.AppointmentItem;
    Whatever item (and message class) I try to add it just ignore it.

    I can't find how I'm supposed to add a meeting to a meeting room calendar by code. Is it possible to see the code that triggers when clicking on the "New Meeting" button in the ribbon? Since that one does exactly what I want, it's just that it is not set to my custom message class. If I call that button command through the commandbar (findcontrol by executing button with ID 1745) with my own button, is it possible to somehow inject another message class before it opens the window? That way I could make it show my form region.

    I basically just need to simulate the meeting button and give it "IPM.Appointment.Visit" as message class so it shows a form region for it.




    Ken Slovak MVP - Outlook
    • Marked as answer by Jimmy-san Tuesday, August 9, 2011 8:37 AM
    Friday, August 5, 2011 3:45 PM
  • Can't get it to work.

    This is frustrating. I have an addin from Microsoft Lync, that adds a button with "New online meeting" that works on room calendars too. I wonder how it's done.

    Is the reason it doesn't seem to work with adding item to the selected folder, because a room calendar doesn't work the same as other calendars? I'm completely new to Outlook (you've probably noticed that) so I'm not sure how these things work. I'm just thinking it must be another way, that the Lync-addin is using, to create a meeting item - assign it to a room calendar and display it. All that the Lync addin seems to do is adding a subject and text to the body of the meeting.

    Monday, August 8, 2011 12:41 PM
  • What's not working?
     
    Does the NewInspector() event fire when the item is opened? Can you then set up and trap the Activate() event on that Inspector? Can you set the MessageClass of the item to your custom MessageClass?
     
    Do you have permissions to create items in that calendar? Can you do so in the user interface?

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Jimmy-san" <=?utf-8?B?SmltbXktc2Fu?=> wrote in message news:6792fd21-33b2-40b3-acdc-345e0bc1b901...

    Can't get it to work.

    This is frustrating. I have an addin from Microsoft Lync, that adds a button with "New online meeting" that works on room calendars too. I wonder how it's done.

    Is the reason it doesn't seem to work with adding item to the selected folder, because a room calendar doesn't work the same as other calendars? I'm completely new to Outlook (you've probably noticed that) so I'm not sure how these things work. I'm just thinking it must be another way, that the Lync-addin is using, to create a meeting item - assign it to a room calendar and display it. All that the Lync addin seems to do is adding a subject and text to the body of the meeting.


    Ken Slovak MVP - Outlook
    Monday, August 8, 2011 1:45 PM
  • I got it to work now it seems, have to do some testing to see it works completely, but thank you so much for helping me!
    Tuesday, August 9, 2011 8:37 AM