Eine der nachfolgenden Berechtigungen ist erforderlich, um diese API aufrufen zu können. Weitere Informationen, unter anderem zur Auswahl von Berechtigungen, finden Sie unter Berechtigungen.
Berechtigungstyp
Berechtigungen (von der Berechtigung mit den wenigsten Rechten zu der mit den meisten Rechten)
Delegiert (Geschäfts-, Schul- oder Unikonto)
Mail.ReadWrite
Delegiert (persönliches Microsoft-Konto)
Mail.ReadWrite
Anwendung
Mail.ReadWrite
HTTP-Anforderung
POST /me/mailFolders/{id}/messages
POST /users/{id | userPrincipalName}/mailFolders/{id}/messages
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new Message
{
ReceivedDateTime = DateTimeOffset.Parse("datetime-value"),
SentDateTime = DateTimeOffset.Parse("datetime-value"),
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("datetime-value");
message.setReceivedDateTime(receivedDateTime);
OffsetDateTime sentDateTime = OffsetDateTime.parse("datetime-value");
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 import GraphServiceClient
from msgraph.generated.models.message import Message
from msgraph.generated.models.item_body import ItemBody
from msgraph.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 = "datetime-value",
sent_date_time = "datetime-value",
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)