Outlook提醒获取AppointmentItem

时间:2015-06-19 16:23:50

标签: c# outlook

有没有办法知道Outlook.reminder是否归AppointmentItem所有? 我有一个eventHandler,它会在触发提醒时被触发。在这种情况下,我想知道哪个Outlook项目拥有提醒,如果它是一个AppointmentItem,如果它符合其他规则来解除提醒。

 storage._Explorers = this.Application.Explorers;
 storage._Explorers.Application.Reminders.ReminderFire += new Outlook.ReminderCollectionEvents_ReminderFireEventHandler(Application_ReminderFire);

...

static void Application_ReminderFire(Outlook.Reminder reminder) {
        object item = reminder.Parent;
        if (item is Outlook.AppointmentItem) {
            AppointmentItem appointment = (item as AppointmentItem);
            MAPIFolder folder = appointment.Parent;

            StringCollection collection = Properties.Settings.Default.CALENDARS_SETTINGS;

            foreach (string chaine in collection) {
                string[] values = chaine.Split(new string[] { "," }, StringSplitOptions.None);
                if (folder.Name == values[0]) {
                    Boolean reminderChecked = Boolean.Parse(values[1]);
                    if (!reminderChecked) {
                        MessageBox.Show(reminder.Caption, "DISMISS", MessageBoxButtons.OK);
                    }
                }
            }
        }
    }

1 个答案:

答案 0 :(得分:1)

使用Reminder.Item属性 - 它会返回相应的AppointmentItemTaskItemMailItem等。您需要检查实际类型和/或投放它到适当的对象。