locked
Outlook how to access the calendar options RRS feed

  • Question

  • Hi,

    I am wanting to access a users current calendar options in C# via a VSTO add in. Specifically their calendar work week properties: StartTime, EndTime and what days of the week they work. I only require 'read' access.

    Outlook 2007, Visual Studio 2008, .net3.5

    Thank you for any help provided.

    Thursday, March 26, 2009 10:24 AM

Answers

  • Hi ,

    There's no any interface exposed in Outlook Object Model to modify the properties you mentioned, the only way I know is via the registry:
    HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Outlook\Options\Calendar
    use your add in to find the values of CalDefStart & CalDefEnd

    Thanks
    We have published a VSTO FAQ recently, you can view them from the entry thread VSTO FAQ.
    If you have any feedbacks or suggestions on this FAQ, please feel free to write us emails to colbertz@microsoft.com.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by Egone Tuesday, March 31, 2009 7:49 AM
    Tuesday, March 31, 2009 6:56 AM

All replies

  • Hi ,

    There's no any interface exposed in Outlook Object Model to modify the properties you mentioned, the only way I know is via the registry:
    HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Outlook\Options\Calendar
    use your add in to find the values of CalDefStart & CalDefEnd

    Thanks
    We have published a VSTO FAQ recently, you can view them from the entry thread VSTO FAQ.
    If you have any feedbacks or suggestions on this FAQ, please feel free to write us emails to colbertz@microsoft.com.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by Egone Tuesday, March 31, 2009 7:49 AM
    Tuesday, March 31, 2009 6:56 AM
  • Posting the final working code.

    using

     

    Microsoft.Win32;

    // Find outlook version

    outlookVersion = MyAddIn.

    Globals.ThisAddIn.Application.Version.ToString();

     

    // Trim outlook version

     

    int pos = outlookVersion.LastIndexOf(".");

     

    if (pos >= 0)

    {

    outlookVersion = outlookVersion.Remove(3, pos + 1);

     

    }

     

    RegistryKey rk = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Office\\" + outlookVersion + "\\Outlook\\Options\\Calendar", false);

     

    string calStart = rk.GetValue("CalDefStart").ToString();

     

    string calEnd = rk.GetValue("CalDefEnd").ToString();

     

    string calWorkDay = rk.GetValue("WorkDay").ToString();

    Thursday, April 2, 2009 8:07 AM
  • Hi,

    how can I change those values?

    I want to synchronize CalDefEnd, CalDefStart and WorkDay from other server using an Outlook COM addin, and if I change only those registry values, after Outlook is closed, old values are set back by Outlook.exe. I discovered that default Calendar folder have an associated message with an XML containing those values, I've tried to delete all associated messages from Calendar folder without any effect. Where is keeping Outlook infos about those settings or how can I change them.

    Friday, October 8, 2010 1:19 PM
  • When Outlook is running it does not read changes to the registry settings. It reads them on startup, maintains them in an in-memory cache and then modifies the cached values if you change something in the options dialogs. It then writes out the settings to the registry when Outlook exits.
     
    If you want to change the settings and have the changes stick you must make the changes when Outlook is not running.

    --
    Ken Slovak
    [MVP - Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007.
    Reminder Manager, Extended Reminders, Attachment Options.
    http://www.slovaktech.com/products.htm
     
     
    "Ciurica" <=?utf-8?B?Q2l1cmljYQ==?=> wrote in message news:92f872b3-f15d-4914-92d7-ec89c1cea94d...

    Hi,

    how can I change those values?

    I want to synchronize CalDefEnd, CalDefStart and WorkDay from other server using an Outlook COM addin, and if I change only those registry values, after Outlook is closed, old values are set back by Outlook.exe. I discovered that default Calendar folder have an associated message with an XML containing those values, I've tried to delete all associated messages from Calendar folder without any effect. Where is keeping Outlook infos about those settings or how can I change them.


    Ken Slovak MVP - Outlook
    Friday, October 8, 2010 2:38 PM
  • OK, tanks for your answer.

    If I change WorkDay value when Outlook is stopped, on first Outlook start in options I can see the value set by me, but when is stopped, Outlook will set back it's old value.

    I change values from: 

    HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Outlook\Options\Calendar for Outlook 2010. HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Outlook\Options\Calendar for Outlook 2007.

    Is there a better way to make this changes permanent?

    Tuesday, October 12, 2010 9:32 AM
  • In 2007 and 2010 the calendar configurations are actually being used from hidden items in the default calendar folder. There are 2 hidden items that would need looking at, IPM.Configuration.Calendar and IPM.Configuration.WorkHours in relation to the calendar defaults. There are also other hidden items for HomeTimeZone and AvailabilityOptions.
     
    I haven't had to use the calendar settings from the hidden items, but looking at them using a MAPI viewer shows that IPM.Configuration.WorkHours has a property PR_ROAMING_XMLSTREAM that appears to have all the calendar settings for work hours as an XML property.
     
    I would imagine that if anything is changed Outlook will write out the new setting to both the registry and the hidden item, but it will only use the hidden item.
     
    --
    Ken Slovak
    [MVP - Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007.
    Reminder Manager, Extended Reminders, Attachment Options.
    http://www.slovaktech.com/products.htm
     
     
    "Ciurica" <=?utf-8?B?Q2l1cmljYQ==?=> wrote in message news:84d34ff3-6b63-4890-8be9-ca4c15c6bf7f...

    OK, tanks for your answer.

    If I change WorkDay value when Outlook is stopped, on first Outlook start in options I can see the value set by me, but when is stopped, Outlook will set back it's old value.

    I change values from: 

    HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Outlook\Options\Calendar for Outlook 2010. HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Outlook\Options\Calendar for Outlook 2007.

    Is there a better way to make this changes permanent?


    Ken Slovak MVP - Outlook
    • Proposed as answer by Ciurica Friday, October 15, 2010 11:50 AM
    Tuesday, October 12, 2010 3:19 PM
  • When Outlook is running it does not read changes to the registry settings. It reads them on startup, maintains them in an in-memory cache and then modifies the cached values if you change something in the options dialogs. It then writes out the settings to the registry when Outlook exits.

    A slight deviation from the behavior you described above: In Outlook 2010, I needed to modify the calendar's secondary timezone but found no way to access it through the object model.  So I resorted to modifying values in the registry, and those values are indeed read when the Explorer switches to CalendarView. 

    In fact, even if the user is viewing the calendar, the changed registry settings take affect when switching to mail and then back to calendar, and the settings are not overwritten.  This makes sense because I would expect the application settings to get written to the registry only when changed through the Outlook's options interface.

    Thursday, April 24, 2014 7:24 PM