创建约会

VSTO

下面的代码片段演示如何创建并保存约会:


   Outlook.AppointmentItem appt = Application.CreateItem(

  Outlook.OlItemType.olAppointmentItem) as Outlook.AppointmentItem;

  appt.Subject = "Developer's Conference";

  appt.AllDayEvent = true;

  appt.Start = DateTime.Parse("6/11/2007 12:00 AM");

  appt.End = DateTime.Parse("6/16/2007 12:00 AM");

  appt.Display(false);

Aspose.Email

创建约会并以 ICS 格式保存需要以下步骤。

  1. 创建 Appointment 类的实例并使用此构造函数进行初始化。
  2. 在上述构造函数中传递以下参数
    1. 与会者
    2. 描述
    3. 结束日期
    4. 地点
    5. 组织者
    6. 开始日期
    7. 摘要
  3. 调用 Save() 方法,并在参数中指定文件名和格式。

该约会可以在 Microsoft Outlook 或任何能够加载ICS文件的程序中打开。如果在 Microsoft Outlook 中打开,该约会会自动添加到 Outlook 日历中。

以下代码片段创建并将约会保存为磁盘上的 ICS 格式文件。


   string location = "Meeting Location: Room 5";

  DateTime startDate = new DateTime(1997, 3, 18, 18, 30, 00),

  endDate = new DateTime(1997, 3, 18, 19, 30, 00);

  MailAddress organizer = new MailAddress("aaa@amail.com", "Organizer");

  MailAddressCollection attendees = new MailAddressCollection();

  attendees.Add(new MailAddress("bbb@bmail.com", "First attendee"));

  Appointment target = new Appointment(location, startDate, endDate, organizer, attendees);

  target.Save("savedFile.ics");

下载示例代码

下载运行代码