共有または委任された予定表内の Outlook イベントを作成する

Outlook では、ユーザーが予定表を他のユーザーと共有し、他のユーザーがその予定表でイベントの表示や作成、変更を行うことができます。 またユーザーは、会議出席依頼の受信と返信や、予定表の項目の作成と変更を自分に代わって対応する代理人を許可することができます。

Microsoft Graph は、他のユーザーによって共有された予定表のイベントの読み取りや書き込み、共有された予定表の表示、共有者用に予定表名の更新を行う機能をプログラムとしてサポートしています。 サポートは、委任された予定表にも適用されます。 この記事の残りの部分では、共有または委任された予定表で会議のイベントを作成する方法について説明します。 イベントを取得する方法については、「共有または委任された予定表内の Outlook イベントを取得する」を参照してください。

次のチュートリアルでは、Alex が Outlook の Adele にプライマリ予定表を委任し、既定の Outlook メールボックス設定を保持して、会議出席依頼と返信を代理人のみに送信するシナリオ例を使用します。 (この設定は、既定値 sendToDelegateOnly として設定された Alex の mailboxSettingsdelegateMeetingMessageDeliveryOptions プロパティに対応しています)。

このチュートリアルでは、後続の手順について説明します。

  1. Alex が委任した予定表を Adele が取得する
  2. Alex の代理人として Adele が Christie と Megan に会議出席依頼を送信する
  3. クリスティは会議出席依頼を受け取り、関連するイベントをカレンダで検査します
  4. Christie が招待を仮承諾する
  5. Adele が Christie の応答メッセージを受信する
  6. Alex がイベントの一部として出席者の応答を確認する

Alex が予定表を Adele と共有しているが委任はしていない場合は、次のようになります。

  • Adele としてサインインすると、アプリは Alex が Adele と共有した予定表を取得できます
  • アプリは手順 2 〜 4 の依頼と返信を使用して、委任された予定表と同じ方法で共有の予定表に適用できます。
  • 手順 5 では、アプリは Adele ではなく Alex としてサインインして、Christie の応答メッセージを受信できます。

手順 1: Adele が委任された予定表を取得する

Adele としてサインインし、自分がアクセスしている予定表を取得して、Alex が委任した予定表を特定します。これにより、次の手順で予定表を使用してイベントを作成できます。

Microsoft Graph のアクセス許可

最も特権の少ない委任されたアクセス許可 Calendars.Read.Shared を使用します。 詳細については、アクセス許可リファレンスの Calendars.Read.Shared アクセス許可を参照してください

GET https://graph.microsoft.com/v1.0/me/calendars

成功した応答には、応答コード HTTP 200、Adele のプライマリ予定表、Adele のメールボックスで Alex によって委任された予定表のコピー、および次のプロパティが含まれています。

  • canShare は false です。Adele は代理人であり、予定表の所有者ではないからです。
  • canEdit は true です。Adele は代理人として、委任された予定表の非公開イベントへの書き込みアクセス権限を持っているからです。
  • ownerAlex Wilber です。これが Alex の予定表であることを示します。
HTTP/1.1 200 OK
Content-type: application/json

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('d3b9214b-dd8b-441d-b7dc-c446c9fa0e69')/calendars",
    "value": [
        {
            "id": "AQMkADGkAAAJMjAAAAA==",
            "name": "Calendar",
            "color": "auto",
            "changeKey": "NDznl+Uh50WkanaCOKHkaQAAAAACXQ==",
            "canShare": true,
            "canViewPrivateItems": true,
            "canEdit": true,
            "owner": {
                "name": "Adele Vance",
                "address": "AdeleV@contoso.com"
            }
        },
        {
            "id": "AAMkADRpAABf0JlzAAA=",
            "name": "Alex Wilber",
            "color": "auto",
            "changeKey": "NDznl+Uh50WkanaCOKHkaQAAX8m4eQ==",
            "canShare": false,
            "canViewPrivateItems": false,
            "canEdit": true,
            "owner": {
                "name": "Alex Wilber",
                "address": "AlexW@contoso.com"
            }
        }
    ]
}

注:

Adele としてサインインしている場合は、GET https://graph.microsoft.com/v1.0/users/AlexW@contoso.com/calendar のように Alex の ID と calendar ショートカットを指定することで、代わりに Alex のメールボックスから委任された予定表を直接取得できます。 返された予定表 ID は、Alex のメールボックスのみに対応しています。

手順 2: Adele が Alex の代理人として招待状を作成し送信する

Adele としてサインインし、手順 1 で取得した予定表 ID を使用して委任された予定表にイベントを作成し、Alex の代理人として Christie と Megan に送信します。

Microsoft Graph のアクセス許可

最も特権の少ない委任されたアクセス許可 Calendars.ReadWrite.Shared を使用します。 詳細については、 アクセス許可リファレンスの「Calendars.ReadWrite.Shared 権限」を参照してください

POST https://graph.microsoft.com/v1.0/me/calendars/AAMkADRpAABf0JlzAAA=/events

Prefer: outlook.timezone="Pacific Standard Time"
Content-type: application/json

{
  "subject": "Christmas dinner",
  "body": {
    "contentType": "HTML",
    "content": "Happy holidays!"
  },
  "start": {
      "dateTime": "2019-12-25T18:00:00",
      "timeZone": "Pacific Standard Time"
  },
  "end": {
      "dateTime": "2019-12-25T22:00:00",
      "timeZone": "Pacific Standard Time"
  },
  "location":{
      "displayName":"Alex' home"
  },
  "attendees": [
    {
      "emailAddress": {
        "address":"meganb@contoso.com",
        "name": "Megan Bowen"
      },
      "type": "required"
    },
    {
      "emailAddress": {
        "address":"ChristieC@contoso.com",
        "name": "Christie Cline"
      },
      "type": "required"
    }
  ]
}
Snippet not available

プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。

成功した応答には、応答コード HTTP 200 と次の eventMessage プロパティが含まれています。

  • meetingMessageType はこのメッセージが meetingRequest であることを指定します。
  • sender は Adele です。
  • from は Alex です。
  • toRecipients には Megan と Christie が含まれます。

また、次のイベント プロパティも含まれています。

  • attendees には、Alex、Megan および Christie が含まれています。
  • organizer は Alex です。

Adele の ID は eventMessagesender プロパティにのみ表示され、関連するイベントには表示されません。

HTTP/1.1 200 OK
Content-type: application/json

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('662b947c-d9a1-4064-926c-eba1316d4462')/messages(microsoft.graph.eventMessage/event())/$entity",
    "@odata.type": "#microsoft.graph.eventMessage",
    "@odata.etag": "W/\"CwAAABYAAADK82uJYVo4RrFV3ADVj3fyAABZ378h\"",
    "id": "AAMkADADVj3fyAABZ5hYdAAA=",
    "createdDateTime": "2019-12-21T04:59:03Z",
    "lastModifiedDateTime": "2019-12-21T04:59:04Z",
    "changeKey": "CwAAABYAAADK82uJYVo4RrFV3ADVj3fyAABZ378h",
    "categories": [],
    "receivedDateTime": "2019-12-21T04:59:03Z",
    "sentDateTime": "2019-12-21T04:59:01Z",
    "hasAttachments": false,
    "internetMessageId": "<DM6PR17MB3593711A1C0A098167F5A977A12C0@DM6PR17MB3593.namprd17.prod.outlook.com>",
    "subject": "Christmas dinner",
    "bodyPreview": "Happy holidays!",
    "importance": "normal",
    "parentFolderId": "AQMkADIAAAIBDAAAAA==",
    "conversationId": "AAQkADNqQlzYAM8jQM=",
    "conversationIndex": "AdW3u1xx5S7TYrbluE2pCXNgAzyNAw==",
    "isDeliveryReceiptRequested": null,
    "isReadReceiptRequested": false,
    "isRead": true,
    "isDraft": false,
    "webLink": "https://outlook.office365.com/owa/?ItemID=AAMkADADVj3fyAABZ5hYdAAA%3D&exvsurl=1&viewmodel=ReadMessageItem",
    "inferenceClassification": "focused",
    "meetingMessageType": "meetingRequest",
    "body": {
        "contentType": "html",
        "content": "<html>\r\n<head>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\r\n<meta content=\"text/html; charset=us-ascii\">\r\n</head>\r\n<body>\r\nHappy holidays!\r\n</body>\r\n</html>\r\n"
    },
    "sender": {
        "emailAddress": {
            "name": "Adele Vance",
            "address": "AdeleV@contoso.com"
        }
    },
    "from": {
        "emailAddress": {
            "name": "Alex Wilber",
            "address": "AlexW@contoso.com"
        }
    },
    "toRecipients": [
        {
            "emailAddress": {
                "name": "Megan Bowen",
                "address": "MeganB@contoso.com"
            }
        },
        {
            "emailAddress": {
                "name": "Christie Cline",
                "address": "ChristieC@contoso.com"
            }
        }
    ],
    "ccRecipients": [],
    "bccRecipients": [],
    "replyTo": [],
    "flag": {
        "flagStatus": "notFlagged"
    },
    "event": {
        "@odata.etag": "W/\"yvNriWFaOEaxVdwA1Y938gAAX+T7Jg==\"",
        "id": "AAMkADADVj3fyAABZ5ieyAAA=",
        "createdDateTime": "2019-12-21T04:59:03.4336242Z",
        "lastModifiedDateTime": "2019-12-27T01:38:32.3766961Z",
        "changeKey": "yvNriWFaOEaxVdwA1Y938gAAX+T7Jg==",
        "categories": [],
        "originalStartTimeZone": "Pacific Standard Time",
        "originalEndTimeZone": "Pacific Standard Time",
        "iCalUId": "040000008200FEFE0BA532444B5FD89BDE22BA103",
        "reminderMinutesBeforeStart": 15,
        "isReminderOn": true,
        "hasAttachments": false,
        "subject": "Christmas dinner",
        "bodyPreview": "Happy holidays!",
        "importance": "normal",
        "sensitivity": "normal",
        "isAllDay": false,
        "isCancelled": false,
        "isOrganizer": false,
        "responseRequested": true,
        "seriesMasterId": null,
        "showAs": "tentative",
        "type": "singleInstance",
        "webLink": "https://outlook.office365.com/owa/?itemid=AAMkADADVj3fyAABZ5ieyAAA%3D&exvsurl=1&path=/calendar/item",
        "onlineMeetingUrl": null,
        "recurrence": null,
        "responseStatus": {
            "response": "none",
            "time": "2019-12-21T05:16:48.8931825Z"
        },
        "body": {
            "contentType": "html",
            "content": "<html>\r\n<head>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\r\n<meta content=\"text/html; charset=us-ascii\">\r\n</head>\r\n<body>\r\nHappy holidays!\r\n</body>\r\n</html>\r\n"
        },
        "start": {
            "dateTime": "2019-12-26T02:00:00.0000000",
            "timeZone": "UTC"
        },
        "end": {
            "dateTime": "2019-12-26T06:00:00.0000000",
            "timeZone": "UTC"
        },
        "location": {
            "displayName": "Alex' home",
            "locationType": "default",
            "uniqueId": "Alex' home",
            "uniqueIdType": "private"
        },
        "locations": [
            {
                "displayName": "Alex' home",
                "locationType": "default",
                "uniqueId": "1396aaf3-e344-4567-a4e3-797557ec24c8",
                "uniqueIdType": "locationStore"
            }
        ],
        "attendees": [
            {
                "type": "required",
                "status": {
                    "response": "none",
                    "time": "0001-01-01T00:00:00Z"
                },
                "emailAddress": {
                    "name": "Alex Wilber",
                    "address": "AlexW@contoso.com"
                }
            },
            {
                "type": "required",
                "status": {
                    "response": "none",
                    "time": "0001-01-01T00:00:00Z"
                },
                "emailAddress": {
                    "name": "Megan Bowen",
                    "address": "MeganB@contoso.com"
                }
            },
            {
                "type": "required",
                "status": {
                    "response": "none",
                    "time": "0001-01-01T00:00:00Z"
                },
                "emailAddress": {
                    "name": "Christie Cline",
                    "address": "ChristieC@contoso.com"
                }
            }
        ],
        "organizer": {
            "emailAddress": {
                "name": "Alex Wilber",
                "address": "AlexW@contoso.com"
            }
        }
    }
}

手順 4: Christie 会議出席依頼に返信する

Christie としてサインインし、イベントに暫定的に応答します。応答には応答メッセージを含めます。

Microsoft Graph のアクセス許可

最も特権の少ない委任されたアクセス許可 Calendars.ReadWrite.Shared を使用します。 詳細については、 アクセス許可リファレンスの「Calendars.ReadWrite.Shared 権限」を参照してください

POST https://graph.microsoft.com/v1.0/me/events/AAMkADADVj3fyAABZ5ieyAAA=/tentativelyAccept
Content-type: application/json

{
  "comment": "I will probably be able to make it.",
  "sendResponse": true
}

成功した応答は、HTTP 202 Accepted を返します。

HTTP/1.1 202 Accepted

手順 5: Adele が応答メッセージを受信する

Adele は Alex のプライマリ予定表の代理人なので、Adele は Alex の代わりに予定表のすべての会議出席依頼の返信を受信します。

Adele としてサインインし、手順 4 で Christie からの応答を表す eventMessage を取得します。

Microsoft Graph のアクセス許可

最も特権の少ない委任されたアクセス許可 Mail.Read.Shared を使用します。 詳細については、アクセス 許可リファレンスの「Mail.Read.Shared 権限」を参照してください

GET https://graph.microsoft.com/v1.0/me/messages/AAMkADI4oeRpAABf0HJUAAA=

成功した応答には、応答コード HTTP 200 と次の eventMessage プロパティが含まれています。

  • meetingMessageTypemeetingTenativelyAccepted です。
  • from は Christie です。
  • toRecipients には Adele のみが含まれ、予定表の所有者である Alex は含まれません。 これは Alex が既定 (Outlook がすべての会議出席依頼の返信を代理人のみに送信する) を維持したからです。
HTTP/1.1 200 OK
Content-type: application/json

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('d3b9214b-dd8b-441d-b7dc-c446c9fa0e69')/messages/$entity",
    "@odata.type": "#microsoft.graph.eventMessage",
    "@odata.etag": "W/\"DAAAABYAAAA0POeX5SHnRaRqdoI4oeRpAABfybkT\"",
    "id": "AAMkADI4oeRpAABf0HJUAAA=",
    "createdDateTime": "2019-12-21T05:16:55Z",
    "lastModifiedDateTime": "2019-12-21T05:16:57Z",
    "changeKey": "DAAAABYAAAA0POeX5SHnRaRqdoI4oeRpAABfybkT",
    "categories": [],
    "receivedDateTime": "2019-12-21T05:16:56Z",
    "sentDateTime": "2019-12-21T05:16:49Z",
    "hasAttachments": false,
    "internetMessageId": "<86880ccb8ec64184996e46eaddaed279@DM6PR17MB3593.namprd17.prod.outlook.com>",
    "subject": "Tentative: Christmas dinner",
    "bodyPreview": "I will probably be able to make it.",
    "importance": "normal",
    "parentFolderId": "AQMkAD5GkAAAIBDAAAAA==",
    "conversationId": "AAQkADK25bhNqQlzYAM8jQM=",
    "conversationIndex": "AdW3u1xx5S7TYrbluE2pCXNgAzyNAwAAoBoZ",
    "isDeliveryReceiptRequested": null,
    "isReadReceiptRequested": false,
    "isRead": false,
    "isDraft": false,
    "webLink": "https://outlook.office365.com/owa/?ItemID=AAMkADI4oeRpAABf0HJUAAA%3D&exvsurl=1&viewmodel=ReadMessageItem",
    "inferenceClassification": "focused",
    "meetingMessageType": "meetingTenativelyAccepted",
    "body": {
        "contentType": "html",
        "content": "<html>\r\n<head>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\r\n<meta content=\"text/html; charset=us-ascii\">\r\n</head>\r\n<body>\r\nI will probably be able to make it.\r\n</body>\r\n</html>\r\n"
    },
    "sender": {
        "emailAddress": {
            "name": "Christie Cline",
            "address": "ChristieC@contoso.com"
        }
    },
    "from": {
        "emailAddress": {
            "name": "Christie Cline",
            "address": "ChristieC@contoso.com"
        }
    },
    "toRecipients": [
        {
            "emailAddress": {
                "name": "Adele Vance",
                "address": "AdeleV@contoso.com"
            }
        }
    ],
    "ccRecipients": [],
    "bccRecipients": [],
    "replyTo": [],
    "flag": {
        "flagStatus": "notFlagged"
    }
}

手順 6: Alex がイベントの一部として応答にアクセスする

Alex は既定で Outlook がすべての会議出席依頼と返信を代理人のみに送信するように設定しているため、Alex は手順 4 からの Christie の応答を受信しません。 ただし、自分のプライマリ予定表のイベントで応答を取得できます。

Alex としてサインインし、手順 2 で Adele が作成したイベントを取得し、attendees プロパティから応答を取得します。

Microsoft Graph のアクセス許可

最も特権の少ない委任されたアクセス許可 Calendars.Read を使用します。 詳細については、アクセス 許可リファレンスの「Calendars.Read 権限」を参照してください

GET https://graph.microsoft.com/v1.0/me/calendar/events/AAMkADJXJGu0AABf02qwAAA=

成功した応答には、応答コード HTTP 200 と次のイベント プロパティが含まれています。

  • isOrganizer は true です。
  • attendees には、Megan と Christie のみが含まれています。
  • attendee インスタンスの status プロパティは、出席者からの応答を示します。
    • Megan の応答は none です。
    • Christie の応答は tentativelyAccepted です。
  • organizer は Alex です。
  • 返されたイベントのプロパティは、代理人 (Adele) を示していません。
HTTP/1.1 200 OK
Content-type: application/json

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('64339082-ed84-4b0b-b4ab-004ae54f3747')/calendars('AQMkADAw7QAAAJfygAAAA%3D%3D')/events/$entity",
    "@odata.etag": "W/\"NEXywgsVrkeNsFsyVyRrtAAAX8xuhA==\"",
    "id": "AAMkADJXJGu0AABf02qwAAA=",
    "createdDateTime": "2019-12-21T04:59:01.4435895Z",
    "lastModifiedDateTime": "2019-12-21T05:16:54.689345Z",
    "changeKey": "NEXywgsVrkeNsFsyVyRrtAAAX8xuhA==",
    "categories": [],
    "originalStartTimeZone": "Pacific Standard Time",
    "originalEndTimeZone": "Pacific Standard Time",
    "iCalUId": "040000008200FEFE0BA532444B5FD89BDE22BA103",
    "reminderMinutesBeforeStart": 15,
    "isReminderOn": true,
    "hasAttachments": false,
    "subject": "Christmas dinner",
    "bodyPreview": "Happy holidays!",
    "importance": "normal",
    "sensitivity": "normal",
    "isAllDay": false,
    "isCancelled": false,
    "isOrganizer": true,
    "responseRequested": true,
    "seriesMasterId": null,
    "showAs": "busy",
    "type": "singleInstance",
    "webLink": "https://outlook.office365.com/owa/?itemid=AAMkADJXJGu0AABf02qwAAA%3D&exvsurl=1&path=/calendar/item",
    "onlineMeetingUrl": null,
    "recurrence": null,
    "responseStatus": {
        "response": "organizer",
        "time": "0001-01-01T00:00:00Z"
    },
    "body": {
        "contentType": "html",
        "content": "<html>\r\n<head>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\r\n<meta content=\"text/html; charset=us-ascii\">\r\n</head>\r\n<body>\r\nHappy holidays!\r\n</body>\r\n</html>\r\n"
    },
    "start": {
        "dateTime": "2019-12-26T02:00:00.0000000",
        "timeZone": "UTC"
    },
    "end": {
        "dateTime": "2019-12-26T06:00:00.0000000",
        "timeZone": "UTC"
    },
    "location": {
        "displayName": "Alex' home",
        "locationType": "default",
        "uniqueId": "Alex' home",
        "uniqueIdType": "private"
    },
    "locations": [
        {
            "displayName": "Alex' home",
            "locationType": "default",
            "uniqueId": "Alex' home",
            "uniqueIdType": "private"
        }
    ],
    "attendees": [
        {
            "type": "required",
            "status": {
                "response": "none",
                "time": "0001-01-01T00:00:00Z"
            },
            "emailAddress": {
                "name": "Megan Bowen",
                "address": "MeganB@contoso.com"
            }
        },
        {
            "type": "required",
            "status": {
                "response": "tentativelyAccepted",
                "time": "2019-12-21T05:16:48.8931825Z"
            },
            "emailAddress": {
                "name": "Christie Cline",
                "address": "ChristieC@contoso.com"
            }
        }
    ],
    "organizer": {
        "emailAddress": {
            "name": "Alex Wilber",
            "address": "AlexW@contoso.com"
        }
    }
}