命名空间:microsoft.graph
获取可供登录 用户使用的一个或多个收件人的邮件提示。
请注意,通过 POST
调用 getMailTips
操作,可以请求一次为多个收件人返回特定类型的邮件提示。 请求的邮件提示在 邮件提示 集合中返回。
此 API 可用于以下国家级云部署。
全局服务 |
美国政府 L4 |
美国政府 L5 (DOD) |
由世纪互联运营的中国 |
✅ |
✅ |
✅ |
❌ |
权限
为此 API 选择标记为最低特权的权限。
只有在应用需要它时,才使用更高的特权权限。 有关委派权限和应用程序权限的详细信息,请参阅权限类型。 要了解有关这些权限的详细信息,请参阅 权限参考。
权限类型 |
最低特权权限 |
更高特权权限 |
委派(工作或学校帐户) |
Mail.Read |
Mail.Read.Shared |
委派(个人 Microsoft 帐户) |
Mail.Read |
不可用。 |
应用程序 |
Mail.Read |
不可用。 |
HTTP 请求
POST /me/getMailTips
POST /users/{id|userPrincipalName}/getMailTips
可选的查询参数
此方法支持 OData 查询参数 来帮助自定义响应。
标头 |
值 |
Authorization |
持有者 {token}。 必填。 详细了解 身份验证和授权。 |
Content-Type |
application/json |
请求正文
在请求正文中,提供具有以下参数的 JSON 对象。
属性 |
类型 |
说明 |
EmailAddresses |
字符串集合 |
要为其获取邮件提示的收件人 SMTP 地址的集合。 |
MailTipsOptions |
String |
表示所请求邮件提示的标志的枚举。 可能的值为:automaticReplies 、、customMailTip 、deliveryRestriction 、moderationStatus externalMemberCount maxMessageSize recipientScope mailboxFullStatus 、recipientSuggestions 、 和 。totalMemberCount |
响应
如果成功,此方法在响应正文中返回响应 200 OK
代码和 mailTips 对象的集合。
示例
请求
以下示例获取指定收件人的邮件提示、任何自动答复设置和邮箱已满状态。
POST https://graph.microsoft.com/v1.0/me/getMailTips
Content-Type: application/json
{
"EmailAddresses": [
"danas@contoso.com",
"fannyd@contoso.com"
],
"MailTipsOptions": "automaticReplies, mailboxFullStatus"
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Me.GetMailTips;
using Microsoft.Graph.Models;
var requestBody = new GetMailTipsPostRequestBody
{
EmailAddresses = new List<string>
{
"danas@contoso.com",
"fannyd@contoso.com",
},
MailTipsOptions = MailTipsType.AutomaticReplies | MailTipsType.MailboxFullStatus,
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Me.GetMailTips.PostAsGetMailTipsPostResponseAsync(requestBody);
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
mgc users get-mail-tips post --user-id {user-id} --body '{\
"EmailAddresses": [\
"danas@contoso.com",\
"fannyd@contoso.com"\
],\
"MailTipsOptions": "automaticReplies, mailboxFullStatus"\
}\
'
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphusers "github.com/microsoftgraph/msgraph-sdk-go/users"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphusers.NewItemGetMailTipsPostRequestBody()
emailAddresses := []string {
"danas@contoso.com",
"fannyd@contoso.com",
}
requestBody.SetEmailAddresses(emailAddresses)
mailTipsOptions := graphmodels.AUTOMATICREPLIES, MAILBOXFULLSTATUS_MAILTIPSTYPE
requestBody.SetMailTipsOptions(&mailTipsOptions)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
getMailTips, err := graphClient.Me().GetMailTips().PostAsGetMailTipsPostResponse(context.Background(), requestBody, nil)
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
com.microsoft.graph.users.item.getmailtips.GetMailTipsPostRequestBody getMailTipsPostRequestBody = new com.microsoft.graph.users.item.getmailtips.GetMailTipsPostRequestBody();
LinkedList<String> emailAddresses = new LinkedList<String>();
emailAddresses.add("danas@contoso.com");
emailAddresses.add("fannyd@contoso.com");
getMailTipsPostRequestBody.setEmailAddresses(emailAddresses);
getMailTipsPostRequestBody.setMailTipsOptions(EnumSet.of(MailTipsType.AutomaticReplies, MailTipsType.MailboxFullStatus));
var result = graphClient.me().getMailTips().post(getMailTipsPostRequestBody);
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
const options = {
authProvider,
};
const client = Client.init(options);
const mailTips = {
EmailAddresses: [
'danas@contoso.com',
'fannyd@contoso.com'
],
MailTipsOptions: 'automaticReplies, mailboxFullStatus'
};
await client.api('/me/getMailTips')
.post(mailTips);
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Users\Item\GetMailTips\GetMailTipsPostRequestBody;
use Microsoft\Graph\Generated\Models\MailTipsType;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new GetMailTipsPostRequestBody();
$requestBody->setEmailAddresses(['danas@contoso.com', 'fannyd@contoso.com', ]);
$requestBody->setMailTipsOptions(new MailTipsType('automaticReplies, mailboxFullStatus'));
$result = $graphServiceClient->me()->getMailTips()->post($requestBody)->wait();
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
Import-Module Microsoft.Graph.Users.Actions
$params = @{
EmailAddresses = @(
"danas@contoso.com"
"fannyd@contoso.com"
)
MailTipsOptions = "automaticReplies, mailboxFullStatus"
}
# A UPN can also be used as -UserId.
Get-MgUserMailTip -UserId $userId -BodyParameter $params
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.users.item.get_mail_tips.get_mail_tips_post_request_body import GetMailTipsPostRequestBody
from msgraph.generated.models.mail_tips_type import MailTipsType
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = GetMailTipsPostRequestBody(
email_addresses = [
"danas@contoso.com",
"fannyd@contoso.com",
],
mail_tips_options = MailTipsType.AutomaticReplies | MailTipsType.MailboxFullStatus,
)
result = await graph_client.me.get_mail_tips.post(request_body)
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
响应
以下示例显示了相应的响应。 注意:为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.context":"https://graph.microsoft.com/v1.0/$metadata#Collection(microsoft.graph.mailTips)",
"value":[
{
"emailAddress":{
"name":"",
"address":"danas@contoso.com"
},
"automaticReplies":{
"message":"<style type=\"text/css\" style=\"\">\r\n<!--\r\np\r\n\t{margin-top:0;\r\n\tmargin-bottom:0}\r\n-->\r\n</style>\r\n<div dir=\"ltr\">\r\n<div id=\"x_divtagdefaultwrapper\" style=\"font-size:12pt; color:#000000; background-color:#FFFFFF; font-family:Calibri,Arial,Helvetica,sans-serif\">\r\n<p>Hi, I am on vacation right now. I'll get back to you after I return.<br>\r\n</p>\r\n</div>\r\n</div>",
"messageLanguage":{
"locale":"en-US",
"displayName":"English (United States)"
},
"scheduledStartTime": {
"dateTime": "2018-08-07T02:00:00.0000000",
"timeZone": "UTC"
},
"scheduledEndTime": {
"dateTime": "2018-08-09T02:00:00.0000000",
"timeZone": "UTC"
}
},
"mailboxFull":false
},
{
"emailAddress":{
"name":"",
"address":"fannyd@contoso.com"
},
"automaticReplies":{
"message":""
},
"mailboxFull":false
}
]
}