microsoftgraph / microsoftgraph/msgraph-sdk-dotnet

SendMailPostRequestBody defaults SaveToSentItems to false in 6.2.0

オープン
#3,167 コメント 1 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

status:waiting-for-triage
主要言語
C#
スター
789
フォーク
264
平均マージ
15時間 17分
マージ済み PR(30日)
3

説明

Describe the bug

Microsoft.Graph 6.2.0 initializes SendMailPostRequestBody.SaveToSentItems to false.

As a result, applications that do not explicitly assign this optional property serialize "saveToSentItems": false.
Messages are delivered successfully but are not saved in the sender's Sent Items folder.

This conflicts with the Microsoft Graph sendMail API contract, which documents saveToSentItems as optional,
defaulting to true, and says it should be specified only when the desired value is false:

https://learn.microsoft.com/en-us/graph/api/user-sendmail?view=graph-rest-1.0

This behavior differs from Microsoft.Graph 5.104.0, where the generated request-body constructor leaves
SaveToSentItems unset (null) and therefore allows the service default to apply.

Expected behavior

Constructing a request body without explicitly assigning SaveToSentItems should omit the property from the
serialized request:

var requestBody = new SendMailPostRequestBody
{
    Message = message,
};

The service should consequently apply its documented default of true, and the sent message should appear in Sent
Items.

Alternatively, if the SDK assigns a client-side default, it should assign true, not false.

How to reproduce

Using Microsoft.Graph 6.2.0:

using Microsoft.Graph;
using Microsoft.Graph.Me.SendMail;
using Microsoft.Graph.Models;

var message = new Message
{
    Subject = "Sent Items reproduction",
    Body = new ItemBody
    {
        ContentType = BodyType.Text,
        Content = "Test message",
    },
    ToRecipients =
    [
        new Recipient
        {
            EmailAddress = new EmailAddress
            {
                Address = "recipient@example.com",
            },
        },
    ],
};

var requestBody = new SendMailPostRequestBody
{
    Message = message,
};

await graphClient.Me.SendMail.PostAsync(requestBody);

Observe that:

  1. The recipient receives the message.
  2. The message is not present in the authenticated sender's Sent Items folder.
  3. The request body serializes saveToSentItems as false.

The compiled 6.2.0 constructor contains the equivalent of:

SaveToSentItems = false;

The same constructor in Microsoft.Graph 5.104.0 does not initialize this property.

SDK Version

6.2.0

Latest version known to work for scenario above?

5.104.0

Known Workarounds

Explicitly assign SaveToSentItems = true:

var requestBody = new SendMailPostRequestBody
{
    Message = message,
    SaveToSentItems = true,
};
Debug output

Relevant constructor IL from Microsoft.Graph 6.2.0:

ldarg.0
ldc.i4.0
newobj System.Void System.Nullable<System.Boolean>::.ctor(!0)
call System.Void
Microsoft.Graph.Me.SendMail.SendMailPostRequestBody::set_SaveToSentItems(System.Nullable<System.Boolean>)

The generated serializer then writes the property:

call System.Nullable<System.Boolean> SendMailPostRequestBody::get_SaveToSentItems()
callvirt System.Void ISerializationWriter::WriteBoolValue(...)

In Microsoft.Graph 5.104.0, the constructor has no corresponding assignment to SaveToSentItems.

Configuration
  • Microsoft.Graph 6.2.0
  • Microsoft.Graph.Core 4.0.1
  • Microsoft.Kiota.Abstractions 2.0.0
  • Microsoft.Kiota.Serialization.Json 2.0.0
  • .NET 10
  • Windows
  • Delegated authentication
  • Endpoint: POST /me/sendMail
Other information

Microsoft.Graph 6.2.0's release notes mention “generation: update request builders and models,” so this appears to
have been introduced by the model-generation update:

https://github.com/microsoftgraph/msgraph-sdk-dotnet/releases/tag/6.2.0

The REST endpoint itself does not appear to be at fault. Omitting saveToSentItems in a direct REST request uses the
documented service default and saves the message in Sent Items.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

生成された SendMailPostRequestBody モデルとそのコンストラクターから始め、次に issue に記載されている 6.2.0 と 5.104.0 のバージョンを比較します。未設定の SaveToSentItems 値に対するシリアル化を検証し、サービスのデフォルト値が /me/sendMail に適用されるように、リクエストで saveToSentItems が省略されることを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
csharp
領域
api, backend
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
活発
明瞭さ
明確に書かれている
初心者へのやさしさ
74/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。