命名空间:microsoft.graph
更新 message 对象的属性。
此 API 可用于以下国家级云部署。
全局服务 |
美国政府 L4 |
美国政府 L5 (DOD) |
由世纪互联运营的中国 |
✅ |
✅ |
✅ |
✅ |
权限
要调用此 API,需要以下权限之一。 若要了解详细信息,包括如何选择权限的信息,请参阅权限。
权限类型 |
权限(从最低特权到最高特权) |
委派(工作或学校帐户) |
Mail.ReadWrite |
委派(个人 Microsoft 帐户) |
Mail.ReadWrite |
应用程序 |
Mail.ReadWrite |
HTTP 请求
PATCH /me/messages/{id}
PATCH /users/{id | userPrincipalName}/messages/{id}
PATCH /me/mailFolders/{id}/messages/{id}
PATCH /users/{id | userPrincipalName}/mailFolders/{id}/messages/{id}
名称 |
类型 |
说明 |
Authorization |
string |
持有者 {token}。 必填。 详细了解 身份验证和授权。 |
Content-Type |
string |
实体正文中的数据性质。 必填。 |
请求正文
在请求正文中,提供应更新的相关字段的值。 请求正文中不包括的现有属性将保留其以前的值,或根据对其他属性值的更改重新计算。 为了实现最佳性能,不得添加未变化的现有值。 可更新以下属性。
属性 |
类型 |
说明 |
bccRecipients |
收件人 |
邮件的密件抄送收件人。 |
body |
ItemBody |
邮件的正文。 仅当 isDraft = true 时可以更新。 |
categories |
String collection |
与邮件关联的类别。 |
ccRecipients |
收件人集合 |
邮件的抄送收件人。 |
flag |
followupFlag |
指示邮件的状态、开始日期、截止日期或完成日期的标志值。 |
发件人 |
收件人 |
邮箱所有者和邮件发件人。 必须对应于使用的实际邮箱。 |
importance |
String |
邮件的重要性。 可能的值包括 Low 、Normal 、High 。 |
inferenceClassification |
String |
根据推导出的相关性或重要性或根据显式重写,对用户邮件的分类。 可能的值为:focused 或 other 。 |
internetMessageId |
String |
由 RFC2822 指定格式的邮件 ID。 仅当 isDraft = true 时可以更新。 |
isDeliveryReceiptRequested |
Boolean |
指示是否需要发送邮件已读回执。 |
isRead |
Boolean |
指示是否已阅读该邮件。 |
isReadReceiptRequested |
Boolean |
指示是否需要发送邮件已读回执。 |
multiValueExtendedProperties |
multiValueLegacyExtendedProperty 集合 |
为邮件定义的多值扩展属性的集合。 可为空。 |
replyTo |
收件人集合 |
在答复时使用的电子邮件地址。 仅当 isDraft = true 时可以更新。 |
sender |
收件人 |
实际用于生成邮件的帐户。 从共享邮箱发送邮件或将邮件作为委托发送时可更新。 在任何情况下,此值必须对应于使用的实际邮箱。 |
singleValueExtendedProperties |
singleValueLegacyExtendedProperty collection |
为邮件定义的单值扩展属性的集合。 可为 NULL。 |
subject |
String |
邮件的主题。 仅当 isDraft = true 时可以更新。 |
toRecipients |
收件人集合 |
邮件的收件人。 |
由于邮件资源支持扩展,因此可以使用 PATCH
操作在现有邮件实例的扩展自定义属性中添加、更新或删除自己的特定于应用的数据。
响应
如果成功,此方法在响应正文中返回 200 OK
响应代码和更新的 message 对象。
示例
请求
以下示例显示了一个请求。
PATCH https://graph.microsoft.com/v1.0/me/messages/{id}
Content-type: application/json
{
"subject": "subject-value",
"body": {
"contentType": "",
"content": "content-value"
},
"inferenceClassification": "other"
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new Message
{
Subject = "subject-value",
Body = new ItemBody
{
ContentType = BodyType.Text,
Content = "content-value",
},
InferenceClassification = InferenceClassificationType.Other,
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Me.Messages["{message-id}"].PatchAsync(requestBody);
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
mgc users messages patch --user-id {user-id} --message-id {message-id} --body '{\
"subject": "subject-value",\
"body": {\
"contentType": "",\
"content": "content-value"\
},\
"inferenceClassification": "other"\
}\
'
有关如何将 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"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewMessage()
subject := "subject-value"
requestBody.SetSubject(&subject)
body := graphmodels.NewItemBody()
contentType := graphmodels.TEXT_BODYTYPE
body.SetContentType(&contentType)
content := "content-value"
body.SetContent(&content)
requestBody.SetBody(body)
inferenceClassification := graphmodels.OTHER_INFERENCECLASSIFICATIONTYPE
requestBody.SetInferenceClassification(&inferenceClassification)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
messages, err := graphClient.Me().Messages().ByMessageId("message-id").Patch(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);
Message message = new Message();
message.setSubject("subject-value");
ItemBody body = new ItemBody();
body.setContentType(BodyType.Text);
body.setContent("content-value");
message.setBody(body);
message.setInferenceClassification(InferenceClassificationType.Other);
Message result = graphClient.me().messages().byMessageId("{message-id}").patch(message);
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
const options = {
authProvider,
};
const client = Client.init(options);
const message = {
subject: 'subject-value',
body: {
contentType: '',
content: 'content-value'
},
inferenceClassification: 'other'
};
await client.api('/me/messages/{id}')
.update(message);
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\Message;
use Microsoft\Graph\Generated\Models\ItemBody;
use Microsoft\Graph\Generated\Models\BodyType;
use Microsoft\Graph\Generated\Models\InferenceClassificationType;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new Message();
$requestBody->setSubject('subject-value');
$body = new ItemBody();
$body->setContentType(new BodyType('text'));
$body->setContent('content-value');
$requestBody->setBody($body);
$requestBody->setInferenceClassification(new InferenceClassificationType('other'));
$result = $graphServiceClient->me()->messages()->byMessageId('message-id')->patch($requestBody)->wait();
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
Import-Module Microsoft.Graph.Mail
$params = @{
subject = "subject-value"
body = @{
contentType = ""
content = "content-value"
}
inferenceClassification = "other"
}
# A UPN can also be used as -UserId.
Update-MgUserMessage -UserId $userId -MessageId $messageId -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.models.message import Message
from msgraph.generated.models.item_body import ItemBody
from msgraph.generated.models.body_type import BodyType
from msgraph.generated.models.inference_classification_type import InferenceClassificationType
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = Message(
subject = "subject-value",
body = ItemBody(
content_type = BodyType.Text,
content = "content-value",
),
inference_classification = InferenceClassificationType.Other,
)
result = await graph_client.me.messages.by_message_id('message-id').patch(request_body)
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
响应
以下示例显示了相应的响应。 注意:为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 200 OK
Content-type: application/json
{
"receivedDateTime": "datetime-value",
"sentDateTime": "datetime-value",
"hasAttachments": true,
"subject": "subject-value",
"body": {
"contentType": "",
"content": "content-value"
},
"bodyPreview": "bodyPreview-value",
"inferenceClassification": "other"
}
相关内容