vb.net - Microsoft Graph SendMail 返回 ErrorInternalServerError
问题描述
我正在编写一个程序,使用官方的 Microsoft Graph 包在 VB.Net 中发送内部电子邮件。起初我用它来发送日历邀请,几个月来效果很好,但是当我尝试添加发送电子邮件的功能时,我不断收到内部服务器错误。
从其他时间来看,人们从 Graph 收到此错误,这似乎是在发送格式错误的请求或给出不太有意义的值时。我正在使用包中的构造函数,并使用与在线每个示例基本相同的构造方法,因此请求的结构不会出错,并且我使用的唯一字段只是接受文本而不做任何东西,所以我认为这也不是问题。
我在 Azure 中拥有正确的权限:Azure 中权限的屏幕截图,包括 Mail.Send
这是我构建电子邮件的代码:
Function DefineImportantEmail(Locations As String, Recipients As List(Of (String, String))) As Message
Dim title = "IMPORTANT OUTAGE NOTIFICATION"
Dim message = "Outage at " & Locations
Dim RecipientList = New List(Of Recipient)
For Each recipient In Recipients
RecipientList.Add(New Attendee With {
.EmailAddress = New EmailAddress With {
.Address = recipient.Item1,
.Name = recipient.Item2
},
.Type = AttendeeType.Optional
})
Next
Return New Message With {
.Subject = title,
.Body = New ItemBody With {
.ContentType = BodyType.Text,
.Content = message
},
.ToRecipients = RecipientList
}
End Function
这是我用来发送电子邮件的代码:
Sub SendImportantEmail(Locations As String, Recipients As List(Of (String, String)))
Dim SaveToSentItems = True
Dim graphClient = GetGraphClient()
Dim EventObject = DefineImportantEmail(Locations, Recipients)
Dim request = graphClient.Users("xxxxx@xxxxxxxxxxxxxxx.com").SendMail(EventObject, SaveToSentItems).Request().PostAsync()
request.Wait()
End Sub
GetGraphClient 函数适用于我尝试过的任何其他 API 端点,所以我没有包含它。被审查的用户来自我们的组织,也是我在该程序的第一个版本中发送日历邀请的用户。
这是我收到的完整错误消息:
(代码:ErrorInternalServerError 消息:发生内部服务器错误。操作失败。ClientRequestId:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx )---> 状态代码:InternalServerError Microsoft.Graph.ServiceException:代码:ErrorInternalServerError 消息:内部服务器发生了错误。操作失败。ClientRequestId: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
解决方案
推荐阅读
- javascript - 确认消息未显示在 javascript 联系表单上
- python - Numpy:genfromtxt 形成元组
- spring-cloud-contract - 错误:找不到存根。请确保调用了 spring-cloud-contract:convert
- c# - .NET Framework 4.5.2.:找到多个相同类型的自定义属性
- android - 如何使用任何框架将 MERN 应用程序转换为移动应用程序
- c - 有人知道不依赖 gcc 的 C 编译器吗?
- javascript - JavaScript TypeError:无法读取未定义的属性“拆分”
- c++ - 为什么等级数是0?
- c# - 多次调用外部静态方法或调用一个内部方法,该方法调用外部静态
- c++ - 如何从二维数组为 QHeightMapSurfaceDataProxy 创建高度图以显示二维傅里叶变换结果