I have created a personal calendar named Time Tracking in Outlook as well as my normal exchange calendar. I have created a Form Region for a simple Outlook AddIn. I want the form region to show only if the appointment is going/derived from the Time Tracking calendar. Below is a screenshot of both calendars.
I want to show the form Region only when it comes from my Time Tracking calendar.
I tried this code:
public partial class TimeTrackingRegionFactory
{
// Occurs before the form region is initialized.
// To prevent the form region from appearing, set e.Cancel to true.
// Use e.OutlookItem to get a reference to the current Outlook item.
private void TimeTrackingRegionFactory_FormRegionInitializing(object sender, Microsoft.Office.Tools.Outlook.FormRegionInitializingEventArgs e)
{
var appt = e.OutlookItem as AppointmentItem;
if (appt != null)
e.Cancel =
!(appt.Parent as Microsoft.Office.Interop.Outlook.MAPIFolder).Name.Equals(
Constants.TIME_TRACKING_CALENDAR);
}
}
However, I found that the calendar name for both is 'Calendar'. I saw this question but I checked and both StoreID and Store properties seem the same.
If I save the appointment and then reopen it, it will say the appointment is from the Time Tracking calendar and then display the form region correctly from the code above.
It is like all appointments seem to be defaulted to the Calendar rather than Time Tracking calendar even though I'm trying to create one from there until it is saved.
Is there a way to find out what calendar the appointment item is being saved to?
Thanks, Bill N