ルールを更新する
-
[アーティクル]
-
-
名前空間: microsoft.graph
messageRule オブジェクトの書き込み可能なプロパティを変更し、変更を保存します。
アクセス許可
この 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 |
ブール値 |
メッセージに対するルールの適用が有効になっているかどうかを示します。 |
| isReadOnly |
Boolean |
ルールが読み取り専用のため、ルールの REST API による変更や削除ができないことを示します。 |
| sequence |
Int32 |
他のルールもある中で、そのルールが実行される順序を示します。 |
応答
成功した場合、このメソッドは 200 OK 応答コードと、応答本文に更新後の messageRule オブジェクトを返します。
例
要求
次の例では、ルールの名前、「ルールを取得する」の例のルールに対して実行するアクションを転送元からアドレスを変更し、その重要度を高くマークします。
PATCH https://graph.microsoft.com/v1.0/me/mailFolders/inbox/messageRules/AQAAAJ5dZqA=
Content-type: application/json
{
"displayName": "Important from partner",
"actions": {
"markImportance": "high"
}
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var messageRule = new MessageRule
{
DisplayName = "Important from partner",
Actions = new MessageRuleActions
{
MarkImportance = Importance.High
}
};
await graphClient.Me.MailFolders["{mailFolder-id}"].MessageRules["{messageRule-id}"]
.Request()
.UpdateAsync(messageRule);
SDK をプロジェクトに追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
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=')
.update(messageRule);
SDK をプロジェクトに追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/me/mailFolders/inbox/messageRules/AQAAAJ5dZqA="]]];
[urlRequest setHTTPMethod:@"PATCH"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
MSGraphMessageRule *messageRule = [[MSGraphMessageRule alloc] init];
[messageRule setDisplayName:@"Important from partner"];
MSGraphMessageRuleActions *actions = [[MSGraphMessageRuleActions alloc] init];
[actions setMarkImportance: [MSGraphImportance high]];
[messageRule setActions:actions];
NSError *error;
NSData *messageRuleData = [messageRule getSerializedDataWithError:&error];
[urlRequest setHTTPBody:messageRuleData];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
SDK をプロジェクトに追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
MessageRule messageRule = new MessageRule();
messageRule.displayName = "Important from partner";
MessageRuleActions actions = new MessageRuleActions();
actions.markImportance = Importance.HIGH;
messageRule.actions = actions;
graphClient.me().mailFolders("inbox").messageRules("AQAAAJ5dZqA=")
.buildRequest()
.patch(messageRule);
SDK をプロジェクトに追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.NewMessageRule()
displayName := "Important from partner"
requestBody.SetDisplayName(&displayName)
actions := msgraphsdk.NewMessageRuleActions()
requestBody.SetActions(actions)
markImportance := "high"
actions.SetMarkImportance(&markImportance)
mailFolderId := "mailFolder-id"
messageRuleId := "messageRule-id"
graphClient.Me().MailFoldersById(&mailFolderId).MessageRulesById(&messageRuleId).Patch(requestBody)
SDK をプロジェクトに追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
Import-Module Microsoft.Graph.Mail
$params = @{
DisplayName = "Important from partner"
Actions = @{
MarkImportance = "high"
}
}
# A UPN can also be used as -UserId.
Update-MgUserMailFolderMessageRule -UserId $userId -MailFolderId $mailFolderId -MessageRuleId $messageRuleId -BodyParameter $params
SDK をプロジェクトに追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
応答
以下に応答の例を示します。注: ここに示す応答オブジェクトは、読みやすさのために短縮されている可能性があります。
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.context":"https://graph.microsoft.com/v1.0/$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"
}
}