次の方法で共有


予定アイテムに異なる受信者の種類を指定する

この例では、OlMeetingRecipientType 列挙値を使用して予定アイテムに異なる受信者の種類を指定する方法を示します。

注:

次のコード サンプルは、『Programming Applications for Microsoft Office Outlook 2007』からの抜粋です。

会議出席依頼を表す AppointmentItem オブジェクトに受信者を追加するには、 OlMeetingRecipientType 列挙値を使用して、メッセージの受信者が必須または任意の出席者か、それともリソース (部屋や機器など) かを指定します。

次のコード例の SetRecipientTypeForAppt では、AppointmentItem オブジェクトを作成し、そのオブジェクトにプロパティを設定して、必須および任意の出席者を追加します。 また、会議用の会議室も追加します。 MeetingStatus プロパティを olMeeting に設定し、予定が会議出席依頼であることを示します。

Visual Studio を使用してこのコード例をテストする場合、Microsoft.Office.Interop.Outlook 名前空間をインポートするときに、まず Microsoft Outlook 15.0 オブジェクト ライブラリ コンポーネントへの参照を追加し、Outlook 変数を指定します。 using ステートメントは、コード例の関数の前に直接置くことはできません。パブリッククラス宣言の前に追加する必要があります。 次のコード行は、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);
}

関連項目