// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new Message
{
ReceivedDateTime = DateTimeOffset.Parse("2016-10-19T10:37:00Z"),
SentDateTime = DateTimeOffset.Parse("2016-10-19T10:37:00Z"),
HasAttachments = true,
Subject = "subject-value",
Body = new ItemBody
{
ContentType = BodyType.Text,
Content = "content-value",
},
BodyPreview = "bodyPreview-value",
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Me.MailFolders["{mailFolder-id}"].Messages.PostAsync(requestBody);
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
Message message = new Message();
OffsetDateTime receivedDateTime = OffsetDateTime.parse("2016-10-19T10:37:00Z");
message.setReceivedDateTime(receivedDateTime);
OffsetDateTime sentDateTime = OffsetDateTime.parse("2016-10-19T10:37:00Z");
message.setSentDateTime(sentDateTime);
message.setHasAttachments(true);
message.setSubject("subject-value");
ItemBody body = new ItemBody();
body.setContentType(BodyType.Text);
body.setContent("content-value");
message.setBody(body);
message.setBodyPreview("bodyPreview-value");
Message result = graphClient.me().mailFolders().byMailFolderId("{mailFolder-id}").messages().post(message);
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.models.message import Message
from msgraph_beta.generated.models.item_body import ItemBody
from msgraph_beta.generated.models.body_type import BodyType
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = Message(
received_date_time = "2016-10-19T10:37:00Z",
sent_date_time = "2016-10-19T10:37:00Z",
has_attachments = True,
subject = "subject-value",
body = ItemBody(
content_type = BodyType.Text,
content = "content-value",
),
body_preview = "bodyPreview-value",
)
result = await graph_client.me.mail_folders.by_mail_folder_id('mailFolder-id').messages.post(request_body)