為約會專案指定不同的收件者類型
此範例示範如何使用 OlMeetingRecipientType 列舉來指定約會專案的不同收件者類型。
範例
注意事項
下列程式代碼範例是 Microsoft Office Outlook 2007 程式設計應用程式的摘錄。
若要將收件者新增至代表會議邀請的 AppointmentItem 物件,請使用 OlMeetingRecipientType 列舉來指定郵件的收件者是必要或選擇性的出席者,還是資源 (,例如會議室或設備) 。
在下列程式代碼範例中,SetRecipientTypeForAppt 會建立 AppointmentItem 對象、設定該物件的屬性,以及新增必要和選擇性的出席者。 它也會為會議新增會議室。 請注意, MeetingStatus 屬性設定為 olMeeting,表示約會是會議邀請。
If you use Visual Studio to test this code example, you must first add a reference to the Microsoft Outlook 15.0 Object Library component and specify the Outlook variable when you import the Microsoft.Office.Interop.Outlook namespace. The using statement must not occur directly before the functions in the code example but must be added before the public Class declaration. The following line of code shows how to do the import and assignment in C#.
using Outlook = Microsoft.Office.Interop.Outlook;
private void SetRecipientTypeForAppt()
{
Outlook.AppointmentItem appt =
Application.CreateItem(
Outlook.OlItemType.olAppointmentItem)
as Outlook.AppointmentItem;
appt.Subject = "Customer Review";
appt.MeetingStatus = Outlook.OlMeetingStatus.olMeeting;
appt.Location = "36/2021";
appt.Start = DateTime.Parse("10/20/2006 10:00 AM");
appt.End = DateTime.Parse("10/20/2006 11:00 AM");
Outlook.Recipient recipRequired =
appt.Recipients.Add("Ryan Gregg");
recipRequired.Type =
(int)Outlook.OlMeetingRecipientType.olRequired;
Outlook.Recipient recipOptional =
appt.Recipients.Add("Peter Allenspach");
recipOptional.Type =
(int)Outlook.OlMeetingRecipientType.olOptional;
Outlook.Recipient recipConf =
appt.Recipients.Add("Conf Room 36/2021 (14) AV");
recipConf.Type =
(int)Outlook.OlMeetingRecipientType.olResource;
appt.Recipients.ResolveAll();
appt.Display(false);
}