gpt4 book ai didi

vb.net - Exchange Web 服务 API : Error Sending Message with Attachment

转载 作者:行者123 更新时间:2023-12-01 06:34:04 25 4
gpt4 key购买 nike

我正在尝试使用 EWS Managed API 2.0 发送带有 PDF 附件的消息。我发送的电子邮件不是我自己的帐户,但我已作为其发送权限。

我可以发送没有附件的电子邮件,但是一旦我尝试发送附件,请求就会失败。

该文件肯定存在。

我已经实现了 TraceListener并看到在 SendAndSaveCopy 时发送了 Create Attachment 请求被调用,但我没有从服务器收到正确的响应(我知道服务器正在收到我的请求,因为错误显然来自服务器)。在创建附件似乎失败后,我没有看到发送电子邮件的请求。

我在尝试 SendAndSaveCopy 时收到的错误是 The request failed. The underlying connection was closed: An unexpected error occurred on a send.内部异常是 Unable to write data to the transport connection: An existing connection was forcibly closed by the remote host.
我已经用谷歌搜索了这个,根据我发现的一些建议,我已经确认这不仅仅是订阅超时(在完全相同的上下文中,我可以在没有附件的情况下使用 SendAndSaveCopy 就可以了,并且还通过事实上我可以在失败后发送错误电子邮件就好了)。其他人提到了文件大小问题,但我的文件大小非常小 (151 KB)。

我的 Exchange 管理员正在检查服务器端是否有可能影响此设置但尚未发现任何设置。

谁能告诉我他们是否遇到过(并找到了解决方案)这个特定问题?甚至我可以指导我的 Exchange 管理员查看有关特定设置的任何提示?

我的代码附在下面(为了可读性,我已经删除了错误消息打印的gobs):

Public Function SendEmailResponse(ByVal strSender As String, ByVal strRecipient As String, ByVal strSubject As String, ByVal strBody As String, _
ByVal ews2010 As ExchangeService, Optional ByVal strCCAddresses As List(Of String) = Nothing, _
Optional ByVal strFilesToAttach As List(Of String) = Nothing, _
Optional ByVal blnReceipt As Boolean = False) As Boolean
Try
Dim msgReply As New EmailMessage(ews2010)
msgReply.Subject = strSubject
msgReply.Body = New MessageBody(BodyType.Text, strBody)
Dim fromAddress As New EmailAddress(strSender)
msgReply.From = fromAddress
msgReply.ToRecipients.Add(strRecipient)
msgReply.IsReadReceiptRequested = blnReceipt
If strCCAddresses IsNot Nothing Then
For Each strCC As String In strCCAddresses
msgReply.CcRecipients.Add(strCC)
Next
End If
msgReply.Save() '''This works just fine

If strFilesToAttach IsNot Nothing Then
For Each flAttach In strFilesToAttach
msgReply.Attachments.AddFileAttachment(flAttach)
Next
End If
msgReply.SendAndSaveCopy() '''CRASHES HERE IF AND ONLY IF I've attached files in the above loop
SendEmailResponse = True
Catch ex As Exception
SendEmailResponse = False
End Try
End Function

最佳答案

From the OP :

My Exchange administrator has tracked down the problem to the load balancer somehow. If I connect directly to the exchange server the problem vanishes; but the autodiscoverurl connects to the load balancer. He's following up on that now. Hopefully I'll have a complete solution up soon, but thought I'd go ahead and post in case this gives anyone any ideas or in case it helps someone else.

关于vb.net - Exchange Web 服务 API : Error Sending Message with Attachment,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16816892/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com