sendmail请求在mime数据上失败

时间:2013-12-20 19:34:13

标签: c# activesync wbxml

我正在使用基于C#的ActiveSync客户端,当我尝试将Sendmail命令发布到服务器时,我遇到了问题。我正在使用以下格式的mime数据进行测试:

    var testMsg = @"From: a@b.com
To: a@b.com
Cc:
Bcc:
Subject: From NSync
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: base64
VGhpcyBpcyB0aGUgYm9keSB0ZXh0Lg==";

    var data = UTF8Encoding.UTF8.GetBytes(testMsg);

当服务器获取数据时,我在Exchange客户端日志中得到此异常:

Command_WorkerThread_Exception : 
--- Exception start ---
Exception type: Microsoft.Exchange.AirSync.Wbxml.WbxmlException
Exception message: Invalid WBXML code/codepage from client
Exception level: 0
Exception stack trace:    at Microsoft.Exchange.AirSync.Wbxml.WbxmlReader.ReadXmlDocument()
   at Microsoft.Exchange.AirSync.AirSyncRequest.get_XmlDocument()
   at Microsoft.Exchange.AirSync.Command.get_XmlRequest()
   at Microsoft.Exchange.AirSync.Command.WorkerThread()
Inner exception follows...
Exception type: System.IndexOutOfRangeException
Exception message: Index was outside the bounds of the array.
Exception level: 1
Exception stack trace:    at Microsoft.Exchange.AirSync.Wbxml.WbxmlSchema30.GetName(Int32 tag)
   at Microsoft.Exchange.AirSync.Wbxml.WbxmlReader.FillXmlElement(XmlElement elem, Int32 depth, Boolean elemIsSecureData, Boolean elemIsBlobData)
   at Microsoft.Exchange.AirSync.Wbxml.WbxmlReader.FillXmlElement(XmlElement elem, Int32 depth, Boolean elemIsSecureData, Boolean elemIsBlobData)
   at Microsoft.Exchange.AirSync.Wbxml.WbxmlReader.ReadXmlDocument()
--- Exception end ---

1 个答案:

答案 0 :(得分:0)

我发现我的问题与正在发送的邮件无关。这个问题与我们序列化为WBXML的方式有关。

在编写不透明数据时,对于MIME内容,您需要首先放置数据长度,然后是字节数组。我编写数据长度的代码已关闭,这导致了问题。