สร้างการนัดหมาย

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");

ดาวน์โหลดโค้ดตัวอย่าง

ดาวน์โหลดโค้ดที่ทำงาน