使用Graph API从共享邮箱发件时无法保存至Sent Items文件夹
使用Graph API从共享邮箱发件后,邮件无法保存到该邮箱的“已发送邮件”文件夹
我们通过Entra应用身份验证,使用Graph API读取并从共享邮箱发送邮件,但发送的邮件无法保存到该共享邮箱的“已发送邮件”文件夹。除该问题外,其余功能均正常:收件人可正常收到邮件,发件人地址也正确设置为共享邮箱地址。
Entra权限

技术环境
ASP.NET应用,使用5.56.0版本的Microsoft.Graph NuGet包。
代码实现
初始化GraphServiceClient代码
private async Task<GraphServiceClient> InitGraphServiceClient() { var clientSecret = await GetClientSecret(); var settings = graphSettings.Value; var credential = new ClientSecretCredential(settings.TenantId, settings.ClientId, clientSecret); return new GraphServiceClient(credential, ["https://graph.microsoft.com/.default"]); }
发送邮件代码
// ... 上方代码省略 var fromAddr = "<shared-mailbox-email-address>"; // 从配置注入 var requestBody = new SendMailPostRequestBody{ Message = new Message { Subject = subject, Body = new ItemBody { ContentType = BodyTypeToGraphApiBodyType(bodyType), Content = body }, ToRecipients = new List<Recipient> { new() { EmailAddress = new EmailAddress { Address = to }, }, }, Attachments = attachments.Select( a => new FileAttachment { OdataType = "#microsoft.graph.fileAttachment", ContentBytes = Convert.FromBase64String(a.Base64Content), Name = a.Name, ContentType = a.ContentType, } as Microsoft.Graph.Models.Attachment ) .ToList() }, SaveToSentItems = true }; var graphServiceClient = await graphServiceClientProvider.GetGraphServiceClientAsync(); await graphServiceClient.Users[fromAddr].SendMail.PostAsync(requestBody);
已尝试的解决方案
- 在请求体中添加
From和/或Sender属性 - 移除
SaveToSentItems = true设置
以上两种方案均无效,寻求解决该问题的方法。
内容的提问来源于stack exchange,提问作者RossM
相关产品推荐
相关产品推荐

