Namespace: microsoft.graph
Create a draft to forward an existing message, in 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.
- Update the draft later to add content to the body or change other message properties.
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.
Send the draft message in a subsequent operation.
Alternatively, forward a message in a single operation.
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/messages/{id}/createForward
POST /users/{id | userPrincipalName}/messages/{id}/createForward
POST /me/mailFolders/{id}/messages/{id}/createForward
POST /users/{id | userPrincipalName}/mailFolders/{id}/messages/{id}/createForward
Request headers
| 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. Use application/json for a JSON object and text/plain for MIME content. |
Request body
This method doesn't require a request body.
However, for creating a forward draft using 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 201 Created response code and a message object 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
Example 1: Create a draft message in JSON format to forward an existing message
The following example shows how to call this API.
Request
The following example shows a request.
POST https://graph.microsoft.com/v1.0/me/messages/AAMkADA1MTAAAH5JaLAAA=/createForward
Content-Type: application/json
{
"message":{
"isDeliveryReceiptRequested": true,
"toRecipients":[
{
"emailAddress": {
"address":"danas@contoso.com",
"name":"Dana Swope"
}
}
]
},
"comment": "Dana, just want to make sure you get this; you'll need this if the project gets approved."
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Me.Messages.Item.CreateForward;
using Microsoft.Graph.Models;
var requestBody = new CreateForwardPostRequestBody
{
Message = new Message
{
IsDeliveryReceiptRequested = true,
ToRecipients = new List<Recipient>
{
new Recipient
{
EmailAddress = new EmailAddress
{
Address = "danas@contoso.com",
Name = "Dana Swope",
},
},
},
},
Comment = "Dana, just want to make sure you get this; you'll need this if the project gets approved.",
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Me.Messages["{message-id}"].CreateForward.PostAsync(requestBody);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphusers "github.com/microsoftgraph/msgraph-sdk-go/users"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphusers.NewItemCreateForwardPostRequestBody()
message := graphmodels.NewMessage()
isDeliveryReceiptRequested := true
message.SetIsDeliveryReceiptRequested(&isDeliveryReceiptRequested)
recipient := graphmodels.NewRecipient()
emailAddress := graphmodels.NewEmailAddress()
address := "danas@contoso.com"
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; you'll need this if the project gets approved."
requestBody.SetComment(&comment)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
createForward, err := graphClient.Me().Messages().ByMessageId("message-id").CreateForward().Post(context.Background(), requestBody, nil)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
com.microsoft.graph.users.item.messages.item.createforward.CreateForwardPostRequestBody createForwardPostRequestBody = new com.microsoft.graph.users.item.messages.item.createforward.CreateForwardPostRequestBody();
Message message = new Message();
message.setIsDeliveryReceiptRequested(true);
LinkedList<Recipient> toRecipients = new LinkedList<Recipient>();
Recipient recipient = new Recipient();
EmailAddress emailAddress = new EmailAddress();
emailAddress.setAddress("danas@contoso.com");
emailAddress.setName("Dana Swope");
recipient.setEmailAddress(emailAddress);
toRecipients.add(recipient);
message.setToRecipients(toRecipients);
createForwardPostRequestBody.setMessage(message);
createForwardPostRequestBody.setComment("Dana, just want to make sure you get this; you'll need this if the project gets approved.");
var result = graphClient.me().messages().byMessageId("{message-id}").createForward().post(createForwardPostRequestBody);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
const options = {
authProvider,
};
const client = Client.init(options);
const message = {
message: {
isDeliveryReceiptRequested: true,
toRecipients: [
{
emailAddress: {
address: 'danas@contoso.com',
name: 'Dana Swope'
}
}
]
},
comment: 'Dana, just want to make sure you get this; you\'ll need this if the project gets approved.'
};
await client.api('/me/messages/AAMkADA1MTAAAH5JaLAAA=/createForward')
.post(message);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Users\Item\Messages\Item\CreateForward\CreateForwardPostRequestBody;
use Microsoft\Graph\Generated\Models\Message;
use Microsoft\Graph\Generated\Models\Recipient;
use Microsoft\Graph\Generated\Models\EmailAddress;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new CreateForwardPostRequestBody();
$message = new Message();
$message->setIsDeliveryReceiptRequested(true);
$toRecipientsRecipient1 = new Recipient();
$toRecipientsRecipient1EmailAddress = new EmailAddress();
$toRecipientsRecipient1EmailAddress->setAddress('danas@contoso.com');
$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; you\'ll need this if the project gets approved.');
$result = $graphServiceClient->me()->messages()->byMessageId('message-id')->createForward()->post($requestBody)->wait();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
Import-Module Microsoft.Graph.Mail
$params = @{
message = @{
isDeliveryReceiptRequested = $true
toRecipients = @(
@{
emailAddress = @{
address = "danas@contoso.com"
name = "Dana Swope"
}
}
)
}
comment = "Dana, just want to make sure you get this; you'll need this if the project gets approved."
}
# A UPN can also be used as -UserId.
New-MgUserMessageForward -UserId $userId -MessageId $messageId -BodyParameter $params
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.users.item.messages.item.create_forward.create_forward_post_request_body import CreateForwardPostRequestBody
from msgraph.generated.models.message import Message
from msgraph.generated.models.recipient import Recipient
from msgraph.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 = CreateForwardPostRequestBody(
message = Message(
is_delivery_receipt_requested = True,
to_recipients = [
Recipient(
email_address = EmailAddress(
address = "danas@contoso.com",
name = "Dana Swope",
),
),
],
),
comment = "Dana, just want to make sure you get this; you'll need this if the project gets approved.",
)
result = await graph_client.me.messages.by_message_id('message-id').create_forward.post(request_body)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
Response
The following example shows the response.
Note: The response object shown here might be shortened for readability.
HTTP/1.1 201 Created
Content-type: application/json
{
"receivedDateTime": "datetime-value",
"sentDateTime": "datetime-value",
"hasAttachments": true,
"subject": "subject-value",
"body": {
"contentType": "",
"content": "content-value"
},
"bodyPreview": "bodyPreview-value"
}
Example 2: Create a draft message in MIME format to forward an existing message
Request
POST https://graph.microsoft.com/v1.0/me/messages/AAMkADA1MTAAAAqldOAAA=/createForward
Content-type: text/plain
RnJvbTogQWxleCBXaWxiZXIgPEFsZXhXQGNvbnRvc28uY29tPgpUbzogTWVnYW4gQm93ZW4gPE1l
Z2FuQkBjb250b3NvLmNvbT4KU3ViamVjdDogSW50ZXJuYWwgUmVzdW1lIFN1Ym1pc3Npb246IFNh
bGVzIEFzc29jaWF0ZQpUaHJlYWQtVG9waWM6IEludGVybmFsIFJlc3VtZSBTdWJtaXNzaW9uOiBT
YWxlcyBBc3NvY2lhdGUKVGhyZWFkLUluZGV4OiBjb2RlY29kZWNvZGVoZXJlaGVyZWhlcmUKRGF0
ZTogU3VuLCAyOCBGZWIgMjAyMSAwNzoxNTowMCArMDAwMApNZXNzYWdlLUlEOgoJPE1XSFBSMTMw
MU1CMjAwMDAwMDAwRDc2RDlDMjgyMjAwMDA5QUQ5QTlASF
Response
The following example shows the response.
HTTP/1.1 201 Created
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('0aaa0aa0-0000-0a00-a00a-0000009000a0')/messages/$entity",
"@odata.etag": "W/\"AAAAAAAAAAAa00AAAa0aAaAa0a0AAAaAAAAaAa0a\"",
"id": "AAMkADA1MTAAAAqldOAAA=",
"createdDateTime": "2021-04-23T18:13:44Z",
"lastModifiedDateTime": "2021-04-23T18:13:44Z",
"changeKey": "AAAAAAAAAAAA00aaaa000aaA",
"categories": [],
"receivedDateTime": "2021-04-23T18:13:44Z",
"sentDateTime": "2021-02-28T07:15:00Z",
"hasAttachments": false,
"internetMessageId": "<AAAAAAAAAA@AAAAAAA0001AA0000.codcod00.prod.outlook.com>",
"subject": "Internal Resume Submission: Sales Associate",
"bodyPreview": "Hi, Megan.I have an interest in the Sales Associate position. Please consider my resume, which you can access here...",
"importance": "normal",
"parentFolderId": "LKJDSKJHkjhfakKJHFKWKKJHKJdhkjHDK==",
"conversationId": "SDSFSmFSDGI5LWZhYjc4fsdfsd=",
"conversationIndex": "Adfsdfsdfsdfw==",
"isDeliveryReceiptRequested": null,
"isReadReceiptRequested": false,
"isRead": true,
"isDraft": true,
"webLink": "https://outlook.office365.com/owa/?ItemID=AAMkAGNhOWAvsurl=1&viewmodel=ReadMessageItem",
"inferenceClassification": "focused",
"body": {
"contentType": "text",
"content": "Hi, Megan.I have an interest in the Sales Associate position. Please consider my resume, which you can access here... Regards,Alex"
},
"sender": {
"emailAddress": {
"name": "Alex Wilber",
"address": "AlexW@contoso.com"
}
},
"from": {
"emailAddress": {
"name": "Alex Wilber",
"address": "AlexW@contoso.com"
}
},
"toRecipients": [
{
"emailAddress": {
"name": "Megan Bowen",
"address": "MeganB@contoso.com"
}
}
],
"ccRecipients": [],
"bccRecipients": [],
"replyTo": [],
"flag": {
"flagStatus": "notFlagged"
}
}
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."
}
}