创建约会项提醒

此代码示例展示了如何使用 ReminderSet 属性创建约会项提醒。

示例

注意

下面的代码示例摘录自 Microsoft Office Outlook 2007 应用程序编程

借助 Outlook,可设置约会提醒,具体方法为使用 AppointmentItem 对象的 ReminderSet 属性。 此属性指明是否已创建约会提醒。 将 ReminderSet 属性设置为 true 即可创建提醒,设置为 false 即可删除提醒。

在下面的代码示例中,ReminderExample 为在加利福尼亚州纳帕市举办的品酒会这一私人约会创建提醒,并设置为在约会开始前提前两小时发出提醒。 首先,ReminderExample 创建 Outlook AppointmentItem 对象。 然后,它将项的 Sensitivity 属性设置为 olPrivate。 这表示约会为私人约会。 设置约会的其他属性(如 StartEnd 时间)后,ReminderExample 设置 ReminderMinutesBeforeStart 属性,指明在约会开始前提前多少分钟发出提醒。 在此代码示例中,ReminderMinutesBeforeStart 设置为 120 分钟(两小时)。

如果使用 Visual Studio 测试此代码示例,必须先添加对 Microsoft Outlook 15.0 对象库组件的引用,并在导入 Microsoft.Office.Interop.Outlook 命名空间时指定 Outlook 变量。 不得将 using 语句直接添加到此代码示例中的函数前面,这个语句必须后跟公共类声明。 下面的代码行演示了如何在 C# 中执行导入和分配。

using Outlook = Microsoft.Office.Interop.Outlook;
private void ReminderExample()
{
    Outlook.AppointmentItem appt = Application.CreateItem(
        Outlook.OlItemType.olAppointmentItem)
        as Outlook.AppointmentItem;
    appt.Subject = "Wine Tasting";
    appt.Location = "Napa CA";
    appt.Sensitivity = Outlook.OlSensitivity.olPrivate;
    appt.Start = DateTime.Parse("10/21/2006 10:00 AM");
    appt.End = DateTime.Parse("10/21/2006 3:00 PM");
    appt.ReminderSet = true;
    appt.ReminderMinutesBeforeStart = 120;
    appt.Save();
}

另请参阅