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.
Forward a message using either JSON or MIME format.
When using JSON format, you can:
- Specify either a comment or the body property of the
message
parameter. Specifying both will return an HTTP 400 Bad Request error.
- Specify either the
toRecipients
parameter or the toRecipients property of the message
parameter. Specifying both or specifying neither will return an HTTP 400 Bad Request error.
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 forward 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 /me/messages/{id}/forward
POST /users/{id | userPrincipalName}/messages/{id}/forward
POST /me/mailFolders/{id}/messages/{id}/forward
POST /users/{id | userPrincipalName}/mailFolders/{id}/messages/{id}/forward
Name |
Type |
Description |
Authorization |
string |
Bearer {token}. Required. Learn more about authentication and authorization. |
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. |
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. |
toRecipients |
recipient collection |
The list of recipients. |
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 ("To", "CC", "BCC", "Subject"), all encoded in base64 format in the request body.
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 sets the isDeliveryReceiptRequested property to true, adds a comment and forwards the message.
Request
The following example shows a request.
POST https://graph.microsoft.com/beta/me/messages/AAMkADA1MTAAAH5JaLAAA=/forward
Content-Type: application/json
{
"message":{
"isDeliveryReceiptRequested": true,
"toRecipients":[
{
"emailAddress": {
"address":"[email protected]",
"name":"Dana Swope"
}
}
]
},
"comment": "Dana, just want to make sure you get this."
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Me.Messages.Item.Forward;
using Microsoft.Graph.Beta.Models;
var requestBody = new ForwardPostRequestBody
{
Message = new Message
{
IsDeliveryReceiptRequested = true,
ToRecipients = new List<Recipient>
{
new Recipient
{
EmailAddress = new EmailAddress
{
Address = "[email protected]",
Name = "Dana Swope",
},
},
},
},
Comment = "Dana, just want to make sure you get this.",
};
// 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}"].Forward.PostAsync(requestBody);
mgc-beta users messages forward post --user-id {user-id} --message-id {message-id} --body '{\
"message":{\
"isDeliveryReceiptRequested": true,\
"toRecipients":[\
{\
"emailAddress": {\
"address":"[email protected]",\
"name":"Dana Swope"\
}\
}\
]\
},\
"comment": "Dana, just want to make sure you get this."\
}\
'
// 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.NewItemForwardPostRequestBody()
message := graphmodels.NewMessage()
isDeliveryReceiptRequested := true
message.SetIsDeliveryReceiptRequested(&isDeliveryReceiptRequested)
recipient := graphmodels.NewRecipient()
emailAddress := graphmodels.NewEmailAddress()
address := "[email protected]"
emailAddress.SetAddress(&address)
name := "Dana Swope"
emailAddress.SetName(&name)
recipient.SetEmailAddress(emailAddress)
toRecipients := []graphmodels.Recipientable {
recipient,
}
message.SetToRecipients(toRecipients)
requestBody.SetMessage(message)
comment := "Dana, just want to make sure you get this."
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").Forward().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.forward.ForwardPostRequestBody forwardPostRequestBody = new com.microsoft.graph.beta.users.item.messages.item.forward.ForwardPostRequestBody();
Message message = new Message();
message.setIsDeliveryReceiptRequested(true);
LinkedList<Recipient> toRecipients = new LinkedList<Recipient>();
Recipient recipient = new Recipient();
EmailAddress emailAddress = new EmailAddress();
emailAddress.setAddress("[email protected]");
emailAddress.setName("Dana Swope");
recipient.setEmailAddress(emailAddress);
toRecipients.add(recipient);
message.setToRecipients(toRecipients);
forwardPostRequestBody.setMessage(message);
forwardPostRequestBody.setComment("Dana, just want to make sure you get this.");
graphClient.me().messages().byMessageId("{message-id}").forward().post(forwardPostRequestBody);
const options = {
authProvider,
};
const client = Client.init(options);
const forward = {
message: {
isDeliveryReceiptRequested: true,
toRecipients: [
{
emailAddress: {
address: '[email protected]',
name: 'Dana Swope'
}
}
]
},
comment: 'Dana, just want to make sure you get this.'
};
await client.api('/me/messages/AAMkADA1MTAAAH5JaLAAA=/forward')
.version('beta')
.post(forward);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Users\Item\Messages\Item\Forward\ForwardPostRequestBody;
use Microsoft\Graph\Beta\Generated\Models\Message;
use Microsoft\Graph\Beta\Generated\Models\Recipient;
use Microsoft\Graph\Beta\Generated\Models\EmailAddress;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new ForwardPostRequestBody();
$message = new Message();
$message->setIsDeliveryReceiptRequested(true);
$toRecipientsRecipient1 = new Recipient();
$toRecipientsRecipient1EmailAddress = new EmailAddress();
$toRecipientsRecipient1EmailAddress->setAddress('[email protected]');
$toRecipientsRecipient1EmailAddress->setName('Dana Swope');
$toRecipientsRecipient1->setEmailAddress($toRecipientsRecipient1EmailAddress);
$toRecipientsArray []= $toRecipientsRecipient1;
$message->setToRecipients($toRecipientsArray);
$requestBody->setMessage($message);
$requestBody->setComment('Dana, just want to make sure you get this.');
$graphServiceClient->me()->messages()->byMessageId('message-id')->forward()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Mail
$params = @{
message = @{
isDeliveryReceiptRequested = $true
toRecipients = @(
@{
emailAddress = @{
address = "[email protected]"
name = "Dana Swope"
}
}
)
}
comment = "Dana, just want to make sure you get this."
}
# A UPN can also be used as -UserId.
Invoke-MgBetaForwardUserMessage -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.forward.forward_post_request_body import ForwardPostRequestBody
from msgraph_beta.generated.models.message import Message
from msgraph_beta.generated.models.recipient import Recipient
from msgraph_beta.generated.models.email_address import EmailAddress
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = ForwardPostRequestBody(
message = Message(
is_delivery_receipt_requested = True,
to_recipients = [
Recipient(
email_address = EmailAddress(
address = "[email protected]",
name = "Dana Swope",
),
),
],
),
comment = "Dana, just want to make sure you get this.",
)
await graph_client.me.messages.by_message_id('message-id').forward.post(request_body)
Response
The following example shows the response.
HTTP/1.1 202 Accepted
POST https://graph.microsoft.com/beta/me/messages/AAMkADA1MTAAAH5JaLAAA=/forward
Content-Type: text/plain
Q29udGVudC1UeXBlOiBhcHBsaWNhdGlvbi9wa2NzNy1taW1lOw0KCW5hbWU9c21pbWUucDdtOw0KCXNtaW1lLXR5cGU9ZW52ZWxvcGVkLWRhdGENCk1pbWUtVmVyc2lvbjogMS4wIChNYWMgT1MgWCBNYWlsIDEzLjAgXCgzNjAxLjAuMTBcKSkNClN1YmplY3Q6IFJlOiBUZXN0aW5nIFMvTUlNRQ0KQ29udGVudC1EaXNwb3Np...
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."
}
}