简体   繁体   English

如何获取要进行约会的Outlook日历

[英]How do I get the Outlook calendar that an appointment is being made to

I have created a personal calendar named Time Tracking in Outlook as well as my normal exchange calendar. 我已经在Outlook中创建了一个名为“ 时间跟踪”的个人日历以及正常的交换日历。 I have created a Form Region for a simple Outlook AddIn. 我已经为一个简单的Outlook加载项创建了一个窗体区域。 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'. 但是,我发现两者的日历名称都是'Calendar'。 I saw this question but I checked and both StoreID and Store properties seem the same. 我看到了这个问题,但是我检查了一下,StoreID和Store属性似乎都相同。

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 谢谢,比尔·N

查看appt.Parent属性-它会返回父MAPIFolder对象。

Dmitry Suggestion Works: 德米特里建议工作:

var outlook = new Microsoft.Office.Interop.Outlook.Application();

e.Cancel = !(outlook.Application.ActiveExplorer().CurrentFolder).Name.Equals(
            Constants.TIME_TRACKING_CALENDAR);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM