获取共享文件夹或委托文件夹中的 Outlook 邮件Get Outlook messages in a shared or delegated folder

使用 Outlook,客户可以与其他人共享邮件文件夹,并授予对各个文件夹的“读取”、“创建”、“修改”或“删除”访问权限。Outlook lets customers share mail folders with one another and provide "read", "create", "modify", or "delete" access to individual folders. 此外,使用 Outlook,客户还可以委托其他用户代表自己执行操作,并访问特定邮件文件夹或客户的整个邮箱;在 Outlook 中,这也称为“委托”。Outlook also allows a customer to delegate another user to act on the customer's behalf, and access specific mail folders or the customer's entire mailbox; this is also known as "delegation" in Outlook.

Microsoft Graph 以编程方式支持在其他用户共享的邮件文件夹中获取邮件,以及获取共享文件夹本身。Programmatically, Microsoft Graph supports getting messages in mail folders that have been shared by other users, as well as getting the shared folders themselves. 此支持还适用于已委托的文件夹。The support also applies to folders that have been delegated.

例如,Garth 已与 John 共享自己的收件箱,并向 John 授予对自己收件箱的读取访问权限。As an example, Garth has shared with John and given read access to Garth's Inbox. 如果 John 已登录应用并授予委托的权限(Mail.Read.Shared 或 Mail.ReadWrite.Shared),应用便能访问 Garth 的邮件和收件箱,如下所述。If John has signed into your app and provided delegated permissions (Mail.Read.Shared or Mail.ReadWrite.Shared), your app will be able to access Garth's mail and Garth's Inbox as described below.

注意通过共享权限(Mail.Read.Shared 或 Mail.ReadWrite.Shared),你可以在共享或委托文件夹中读取或写入邮件。Note The sharing permissions (Mail.Read.Shared or Mail.ReadWrite.Shared) allow you to read or write messages in a shared or delegated folder. 它们不支持订阅此类文件夹中的项的更改通知They do not support subscribing to change notifications on items in such folders. 若要对租户中共享、委托或任何其他用户的邮件文件夹中的邮件设置更改通知订阅,请使用应用程序权限 Mail.Read。To set up change notification subscriptions on messages in a shared, delegated, or any other user's mail folder in the tenant, use the application permission, Mail.Read.

获取共享文件夹中的邮件Get a message in the shared folder

你可以在 Garth 的收件箱中获取特定邮件:You can get a specific message in Garth's Inbox:

GET users/{Garth-userId | Garth-userPrincipalName}/mailfolders('Inbox')/messages/{id}

成功完成后,你将收到“HTTP 200 正常”消息和由来自 Garth 收件箱的 {id} 标识的消息实例。On successful completion, you'll get HTTP 200 OK and the message instance identified by {id} from Garth's Inbox.

获取共享文件夹中的全部邮件Get all messages in the shared folder

获取 Garth 收件箱中的所有邮件:Get all the messages in Garth's Inbox:

GET users/{Garth-userId | Garth-userPrincipalName}/mailfolders('Inbox')/messages

成功完成后,你将收到“HTTP 200 正常”消息和 Garth 收件箱中的消息实例的集合。On successful completion, you'll get HTTP 200 OK and a collection of message instances in Garth's Inbox.

获取共享文件夹Get the shared folder

获取 Garth 与 John 共享的文件夹(收件箱)。Get the folder (Inbox) that Garth has shared with John.

GET users/{Garth-userId | Garth-userPrincipalName}/mailfolders('Inbox')

成功完成后,你将收到“HTTP 200 正常”消息和表示 Garth 收件箱文件夹的 mailFolder 实例。On successful completion, you'll get HTTP 200 OK and a mailFolder instance that represents Garth's Inbox folder.

如果 Garth 已经委派 John 进一步访问他的收件箱,或者如果 Garth 已将其整个邮箱委派给 John,那么可应用相同的 GET 功能。The same GET capabilities apply if Garth had delegated John further access to Garth's Inbox, or if Garth had delegated John his entire mailbox.

如果 Garth 既未与 John 共享自己的收件箱,也未将自己的邮箱委托给 John,那么在这些 GET 操作中指定 Garth 的用户 ID 或用户主体名称便会返回错误。If Garth has not shared his Inbox with John, nor has he delegated his mailbox to John, specifying Garth’s user ID or user principal name in those GET operations will return an error.

后续步骤Next steps

详细了解以下信息:Find out more about: