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.
Reply to all recipients of a message using either JSON or MIME format.
When using JSON format:
- Specify either a comment or the body property of the
message
parameter. Specifying both will return an HTTP 400 Bad Request error.
- If the original message specifies a recipient in the replyTo property, per Internet Message Format (RFC 2822), send the reply to the recipients in replyTo and not the recipient in the from property.
When using MIME format:
- Provide the applicable Internet message headers and the MIME content, all encoded in base64 format in the request body.
- Add any attachments and S/MIME properties to the MIME content.
This method saves the message in the Sent Items folder.
Alternatively, create a draft to reply-all to a message, and send it later.
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.Send |
Not available. |
Delegated (personal Microsoft account) |
Mail.Send |
Not available. |
Application |
Mail.Send |
Not available. |
HTTP request
POST /users/me/messages/{id}/replyAll
POST /users/{id | userPrincipalName}/messages/{id}/replyAll
POST /me/mailFolders/{id}/messages/{id}/replyAll
POST /users/{id | userPrincipalName}/mailFolders/{id}/messages/{id}/replyAll
Name |
Type |
Description |
Authorization |
string |
Bearer {token}. Required |
Content-Type |
string |
Nature of the data in the body of an entity. Required Use application/json for a JSON object and text/plain for MIME content |
Prefer: outlook.timezone |
string |
Sets the time zone for the Sent field of the reply message in HTML that this API creates based on the request body. The value can be any of the supportedTimeZones configured for the user. If not specified, that Sent field is in UTC.
Use this header only if you're specifying the Content-Type: application/json header to create the reply message in HTML. If you use the Content-Type: text/plain header, this Prefer header does not have any effect. Optional. |
Request body
When using JSON format, provide a JSON object with the following parameters.
Parameter |
Type |
Description |
comment |
String |
A comment to include. Can be an empty string. |
message |
message |
Any writeable properties to update in the reply message. |
When specifying the body in MIME format, provide the MIME content with the applicable Internet message headers, all encoded in base64 format in the request body. This method loads the sender and all recipients of the original message as recipients of the new message.
Response
If successful, this method returns 202 Accepted
response code. It doesn't return anything in the response body.
If the request body includes malformed MIME content, this method returns 400 Bad request
and the following error message: "Invalid base64 string for MIME content".
Examples
The following example includes a comment and adds an attachment to the reply-all message.
Request
The following example shows a request.
POST https://graph.microsoft.com/beta/me/messages/AAMkADA1MTAAAH5JaKAAA=/replyAll
Content-Type: application/json
{
"message":{
"attachments": [
{
"@odata.type": "#microsoft.graph.fileAttachment",
"name": "guidelines.txt",
"contentBytes": "bWFjIGFuZCBjaGVlc2UgdG9kYXk="
}
]
},
"comment": "Please take a look at the attached guidelines before you decide on the name."
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Me.Messages.Item.ReplyAll;
using Microsoft.Graph.Beta.Models;
var requestBody = new ReplyAllPostRequestBody
{
Message = new Message
{
Attachments = new List<Attachment>
{
new FileAttachment
{
OdataType = "#microsoft.graph.fileAttachment",
Name = "guidelines.txt",
ContentBytes = Convert.FromBase64String("bWFjIGFuZCBjaGVlc2UgdG9kYXk="),
},
},
},
Comment = "Please take a look at the attached guidelines before you decide on the name.",
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
await graphClient.Me.Messages["{message-id}"].ReplyAll.PostAsync(requestBody);
mgc-beta users messages reply-all post --user-id {user-id} --message-id {message-id} --body '{\
"message":{\
"attachments": [\
{\
"@odata.type": "#microsoft.graph.fileAttachment",\
"name": "guidelines.txt",\
"contentBytes": "bWFjIGFuZCBjaGVlc2UgdG9kYXk="\
}\
]\
},\
"comment": "Please take a look at the attached guidelines before you decide on the name."\
}\
'
// 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"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphusers.NewItemReplyAllPostRequestBody()
message := graphmodels.NewMessage()
attachment := graphmodels.NewFileAttachment()
name := "guidelines.txt"
attachment.SetName(&name)
contentBytes := []byte("bWFjIGFuZCBjaGVlc2UgdG9kYXk=")
attachment.SetContentBytes(&contentBytes)
attachments := []graphmodels.Attachmentable {
attachment,
}
message.SetAttachments(attachments)
requestBody.SetMessage(message)
comment := "Please take a look at the attached guidelines before you decide on the name."
requestBody.SetComment(&comment)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
graphClient.Me().Messages().ByMessageId("message-id").ReplyAll().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.messages.item.replyall.ReplyAllPostRequestBody replyAllPostRequestBody = new com.microsoft.graph.beta.users.item.messages.item.replyall.ReplyAllPostRequestBody();
Message message = new Message();
LinkedList<Attachment> attachments = new LinkedList<Attachment>();
FileAttachment attachment = new FileAttachment();
attachment.setOdataType("#microsoft.graph.fileAttachment");
attachment.setName("guidelines.txt");
byte[] contentBytes = Base64.getDecoder().decode("bWFjIGFuZCBjaGVlc2UgdG9kYXk=");
attachment.setContentBytes(contentBytes);
attachments.add(attachment);
message.setAttachments(attachments);
replyAllPostRequestBody.setMessage(message);
replyAllPostRequestBody.setComment("Please take a look at the attached guidelines before you decide on the name.");
graphClient.me().messages().byMessageId("{message-id}").replyAll().post(replyAllPostRequestBody);
const options = {
authProvider,
};
const client = Client.init(options);
const replyAll = {
message: {
attachments: [
{
'@odata.type': '#microsoft.graph.fileAttachment',
name: 'guidelines.txt',
contentBytes: 'bWFjIGFuZCBjaGVlc2UgdG9kYXk='
}
]
},
comment: 'Please take a look at the attached guidelines before you decide on the name.'
};
await client.api('/me/messages/AAMkADA1MTAAAH5JaKAAA=/replyAll')
.version('beta')
.post(replyAll);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Users\Item\Messages\Item\ReplyAll\ReplyAllPostRequestBody;
use Microsoft\Graph\Beta\Generated\Models\Message;
use Microsoft\Graph\Beta\Generated\Models\Attachment;
use Microsoft\Graph\Beta\Generated\Models\FileAttachment;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new ReplyAllPostRequestBody();
$message = new Message();
$attachmentsAttachment1 = new FileAttachment();
$attachmentsAttachment1->setOdataType('#microsoft.graph.fileAttachment');
$attachmentsAttachment1->setName('guidelines.txt');
$attachmentsAttachment1->setContentBytes(\GuzzleHttp\Psr7\Utils::streamFor(base64_decode('bWFjIGFuZCBjaGVlc2UgdG9kYXk=')));
$attachmentsArray []= $attachmentsAttachment1;
$message->setAttachments($attachmentsArray);
$requestBody->setMessage($message);
$requestBody->setComment('Please take a look at the attached guidelines before you decide on the name.');
$graphServiceClient->me()->messages()->byMessageId('message-id')->replyAll()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Mail
$params = @{
message = @{
attachments = @(
@{
"@odata.type" = "#microsoft.graph.fileAttachment"
name = "guidelines.txt"
contentBytes = "bWFjIGFuZCBjaGVlc2UgdG9kYXk="
}
)
}
comment = "Please take a look at the attached guidelines before you decide on the name."
}
# A UPN can also be used as -UserId.
Invoke-MgBetaReplyAllUserMessage -UserId $userId -MessageId $messageId -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.messages.item.reply_all.reply_all_post_request_body import ReplyAllPostRequestBody
from msgraph_beta.generated.models.message import Message
from msgraph_beta.generated.models.attachment import Attachment
from msgraph_beta.generated.models.file_attachment import FileAttachment
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = ReplyAllPostRequestBody(
message = Message(
attachments = [
FileAttachment(
odata_type = "#microsoft.graph.fileAttachment",
name = "guidelines.txt",
content_bytes = base64.urlsafe_b64decode("bWFjIGFuZCBjaGVlc2UgdG9kYXk="),
),
],
),
comment = "Please take a look at the attached guidelines before you decide on the name.",
)
await graph_client.me.messages.by_message_id('message-id').reply_all.post(request_body)
Response
The following example shows the response.
HTTP/1.1 202 Accepted
Request
POST https://graph.microsoft.com/beta/me/messages/AAMkADA1MTAAAH5JaLAAA=/replyAll
Content-Type: text/plain
RnJvbTogQWxleCBXaWxiZXIgPEFsZXhXQGNvbnRvc28uY29tPgpUbzogTWVnYW4gQm93ZW4gPE1l
Z2FuQkBjb250b3NvLmNvbT4KU3ViamVjdDogSW50ZXJuYWwgUmVzdW1lIFN1Ym1pc3Npb246IFNh
bGVzIEFzc29jaWF0ZQpUaHJlYWQtVG9waWM...
Response
The following example shows the response.
HTTP/1.1 202 Accepted
If the request body includes malformed MIME content, this method returns the following error message.
HTTP/1.1 400 Bad Request
Content-type: application/json
{
"error": {
"code": "ErrorMimeContentInvalidBase64String",
"message": "Invalid base64 string for MIME content."
}
}