名前空間: microsoft.graph
重要
Microsoft Graph の /beta バージョンの API は変更される可能性があります。 実稼働アプリケーションでこれらの API を使用することは、サポートされていません。 v1.0 で API を使用できるかどうかを確認するには、Version セレクターを使用します。
messageRule オブジェクトの書き込み可能なプロパティを変更し、変更を保存します。
この API は、次の国内クラウド展開で使用できます。
| グローバル サービス |
米国政府機関 L4 |
米国政府機関 L5 (DOD) |
21Vianet が運営する中国 |
| ✅ |
✅ |
✅ |
❌ |
アクセス許可
この API の最小特権としてマークされているアクセス許可またはアクセス許可を選択します。
アプリで必要な場合にのみ、より高い特権のアクセス許可またはアクセス許可を使用します。 委任されたアクセス許可とアプリケーションのアクセス許可の詳細については、「アクセス許可の種類」を参照してください。 これらのアクセス許可の詳細については、「アクセス許可のリファレンス」を参照してください。
| アクセス許可の種類 |
最小特権アクセス許可 |
より高い特権のアクセス許可 |
| 委任 (職場または学校のアカウント) |
MailboxSettings.ReadWrite |
注意事項なし。 |
| 委任 (個人用 Microsoft アカウント) |
MailboxSettings.ReadWrite |
注意事項なし。 |
| アプリケーション |
MailboxSettings.ReadWrite |
注意事項なし。 |
HTTP 要求
PATCH /me/mailFolders/inbox/messageRules/{id}
PATCH /users/{id | userPrincipalName}/mailFolders/inbox/messageRules/{id}
| 名前 |
説明 |
| Authorization |
ベアラー {token}。 必須です。
認証と認可についての詳細をご覧ください。 |
要求本文
要求本文で、更新する関連フィールドの値を指定します。 要求本文に含まれない既存のプロパティは、以前の値のままになるか、他のプロパティ値の変化に基づいて再計算されます。 最適なパフォーマンスを得るためには、変更されていない既存の値を含めないでください。
| プロパティ |
型 |
説明 |
| actions |
messageRuleActions |
該当する条件が満たされた場合にメッセージに対して実行されるアクション。 |
| conditions |
messageRulePredicates |
該当するルール アクションをトリガーするために満たす必要のある条件。 |
| displayName |
String |
ルールの表示名。 |
| exceptions |
messageRulePredicates |
ルールの例外条件。 |
| isEnabled |
Boolean |
メッセージに対するルールの適用が有効になっているかどうかを示します。 |
| isReadOnly |
Boolean |
ルールが読み取り専用のため、ルールの REST API による変更や削除ができないことを示します。 |
| sequence |
Int32 |
他のルールもある中で、そのルールが実行される順序を示します。 |
応答
成功した場合、このメソッドは 200 OK 応答コードと、応答本文に更新後の messageRule オブジェクトを返します。
例
要求
次の例では、ルールの名前、「ルールを取得する」の例のルールに対して実行するアクションを転送元からアドレスを変更し、その重要度を高くマークします。
PATCH https://graph.microsoft.com/beta/me/mailFolders/inbox/messageRules/AQAAAJ5dZqA=
Content-type: application/json
{
"displayName": "Important from partner",
"actions": {
"markImportance": "high"
}
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new MessageRule
{
DisplayName = "Important from partner",
Actions = new MessageRuleActions
{
MarkImportance = Importance.High,
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Me.MailFolders["{mailFolder-id}"].MessageRules["{messageRule-id}"].PatchAsync(requestBody);
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewMessageRule()
displayName := "Important from partner"
requestBody.SetDisplayName(&displayName)
actions := graphmodels.NewMessageRuleActions()
markImportance := graphmodels.HIGH_IMPORTANCE
actions.SetMarkImportance(&markImportance)
requestBody.SetActions(actions)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
messageRules, err := graphClient.Me().MailFolders().ByMailFolderId("mailFolder-id").MessageRules().ByMessageRuleId("messageRule-id").Patch(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
MessageRule messageRule = new MessageRule();
messageRule.setDisplayName("Important from partner");
MessageRuleActions actions = new MessageRuleActions();
actions.setMarkImportance(Importance.High);
messageRule.setActions(actions);
MessageRule result = graphClient.me().mailFolders().byMailFolderId("{mailFolder-id}").messageRules().byMessageRuleId("{messageRule-id}").patch(messageRule);
const options = {
authProvider,
};
const client = Client.init(options);
const messageRule = {
displayName: 'Important from partner',
actions: {
markImportance: 'high'
}
};
await client.api('/me/mailFolders/inbox/messageRules/AQAAAJ5dZqA=')
.version('beta')
.update(messageRule);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\MessageRule;
use Microsoft\Graph\Beta\Generated\Models\MessageRuleActions;
use Microsoft\Graph\Beta\Generated\Models\Importance;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new MessageRule();
$requestBody->setDisplayName('Important from partner');
$actions = new MessageRuleActions();
$actions->setMarkImportance(new Importance('high'));
$requestBody->setActions($actions);
$result = $graphServiceClient->me()->mailFolders()->byMailFolderId('mailFolder-id')->messageRules()->byMessageRuleId('messageRule-id')->patch($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Mail
$params = @{
displayName = "Important from partner"
actions = @{
markImportance = "high"
}
}
# A UPN can also be used as -UserId.
Update-MgBetaUserMailFolderMessageRule -UserId $userId -MailFolderId $mailFolderId -MessageRuleId $messageRuleId -BodyParameter $params
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.models.message_rule import MessageRule
from msgraph_beta.generated.models.message_rule_actions import MessageRuleActions
from msgraph_beta.generated.models.importance import Importance
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = MessageRule(
display_name = "Important from partner",
actions = MessageRuleActions(
mark_importance = Importance.High,
),
)
result = await graph_client.me.mail_folders.by_mail_folder_id('mailFolder-id').message_rules.by_message_rule_id('messageRule-id').patch(request_body)
応答
次の例は応答を示しています。 注: ここに示す応答オブジェクトは、読みやすさのために短縮されている場合があります。
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.context":"https://graph.microsoft.com/beta/$metadata#Me/mailFolders('inbox')/messageRules/$entity",
"id":"AQAAAJ5dZqA=",
"displayName":"Important from partner",
"sequence":2,
"isEnabled":true,
"hasError":false,
"isReadOnly":false,
"conditions":{
"senderContains":[
"ADELE"
]
},
"actions":{
"markImportance": "high"
}
}