Namespace: microsoft.graph
Important
APIs under the /beta
version in Microsoft Graph are subject to change. Use of these APIs in production applications is not supported. To determine whether an API is available in v1.0, use the Version selector.
Update the read state of all messages in a mailFolder object.
This API is available in the following national cloud deployments.
Global service |
US Government L4 |
US Government L5 (DOD) |
China operated by 21Vianet |
✅ |
❌ |
❌ |
❌ |
Permissions
Choose the permission or permissions marked as least privileged for this API. Use a higher privileged permission or permissions only if your app requires it. For details about delegated and application permissions, see Permission types. To learn more about these permissions, see the permissions reference.
Permission type |
Least privileged permissions |
Higher privileged permissions |
Delegated (work or school account) |
Mail.ReadWrite |
Not available. |
Delegated (personal Microsoft account) |
Mail.ReadWrite |
Not available. |
Application |
Mail.ReadWrite |
Not available. |
HTTP request
POST /me/mailFolders/{mailFolderId}/updateAllMessagesReadState
POST /users/{userId}/mailFolders/{mailFolderId}/updateAllMessagesReadState
Request body
In the request body, supply a JSON representation of the parameters.
The following table lists the parameters that are required when you call this action.
Parameter |
Type |
Description |
isRead |
Boolean |
Indicates whether to mark messages as read or unread. |
suppressReadReceipts |
Boolean |
Indicates whether to suppress the read receipts for messages from the receiving end. |
Response
If successful, this action returns a 204 No Content
response code.
Examples
Request
The following example shows a request.
POST https://graph.microsoft.com/beta/me/mailFolders/AAMkAGVmMDEzM/updateAllMessagesReadState
Content-Type: application/json
{
"isRead": "true",
"suppressReadReceipts": "true"
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Me.MailFolders.Item.UpdateAllMessagesReadState;
var requestBody = new UpdateAllMessagesReadStatePostRequestBody
{
IsRead = true,
SuppressReadReceipts = true,
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
await graphClient.Me.MailFolders["{mailFolder-id}"].UpdateAllMessagesReadState.PostAsync(requestBody);
mgc-beta users mail-folders update-all-messages-read-state post --user-id {user-id} --mail-folder-id {mailFolder-id} --body '{\
"isRead": "true",\
"suppressReadReceipts": "true"\
}\
'
// 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"
graphusers "github.com/microsoftgraph/msgraph-beta-sdk-go/users"
//other-imports
)
requestBody := graphusers.NewItemUpdateAllMessagesReadStatePostRequestBody()
isRead := true
requestBody.SetIsRead(&isRead)
suppressReadReceipts := true
requestBody.SetSuppressReadReceipts(&suppressReadReceipts)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
graphClient.Me().MailFolders().ByMailFolderId("mailFolder-id").UpdateAllMessagesReadState().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
com.microsoft.graph.beta.users.item.mailfolders.item.updateallmessagesreadstate.UpdateAllMessagesReadStatePostRequestBody updateAllMessagesReadStatePostRequestBody = new com.microsoft.graph.beta.users.item.mailfolders.item.updateallmessagesreadstate.UpdateAllMessagesReadStatePostRequestBody();
updateAllMessagesReadStatePostRequestBody.setIsRead(true);
updateAllMessagesReadStatePostRequestBody.setSuppressReadReceipts(true);
graphClient.me().mailFolders().byMailFolderId("{mailFolder-id}").updateAllMessagesReadState().post(updateAllMessagesReadStatePostRequestBody);
const options = {
authProvider,
};
const client = Client.init(options);
const updateAllMessagesReadState = {
isRead: 'true',
suppressReadReceipts: 'true'
};
await client.api('/me/mailFolders/AAMkAGVmMDEzM/updateAllMessagesReadState')
.version('beta')
.post(updateAllMessagesReadState);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Users\Item\MailFolders\Item\UpdateAllMessagesReadState\UpdateAllMessagesReadStatePostRequestBody;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new UpdateAllMessagesReadStatePostRequestBody();
$requestBody->setIsRead(true);
$requestBody->setSuppressReadReceipts(true);
$graphServiceClient->me()->mailFolders()->byMailFolderId('mailFolder-id')->updateAllMessagesReadState()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Mail
$params = @{
isRead = "true"
suppressReadReceipts = "true"
}
# A UPN can also be used as -UserId.
Update-MgBetaUserMailFolderMessageReadState -UserId $userId -MailFolderId $mailFolderId -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.users.item.mailfolders.item.update_all_messages_read_state.update_all_messages_read_state_post_request_body import UpdateAllMessagesReadStatePostRequestBody
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = UpdateAllMessagesReadStatePostRequestBody(
is_read = True,
suppress_read_receipts = True,
)
await graph_client.me.mail_folders.by_mail_folder_id('mailFolder-id').update_all_messages_read_state.post(request_body)
Response
The following example shows the response.
HTTP/1.1 204 No Content