biztalk-2016 - BizTalk - 设置电子邮件 contentType 导致错误:XML 文档中存在错误 (1, 1)
问题描述
当我尝试在 BizTalk 业务流程中设置 Microsoft.XLANGs.BaseTypes.ContentType 时,我收到一个 XML 错误(无论我使用的是“text/plain”还是“text/xml”。我使用的是动态发送端口PassThru 管道。
msg_Email.BodyPart = new Ledger6002.Component.RawString("See attached email. Method 2");
msg_Email.AttachmentPart = msg_Ledger6002_File_XmlDoc;
// Set the filename as it should display on the attachment in the email
// (drop the path, just the filename/extension)
attachmentName = System.IO.Path.GetFileName(
msg_Ledger6002_File_XmlDoc(FILE.ReceivedFileName));
msg_Email.AttachmentPart(MIME.FileName) = attachmentName;
msg_Email.BodyPart(Microsoft.XLANGs.BaseTypes.ContentType) = "text/plain";
msg_Email.AttachmentPart(Microsoft.XLANGs.BaseTypes.ContentType) = "text/plain";
导致此错误:
xlang/s engine event log entry: Uncaught exception (see the 'inner exception' below) has suspended an instance of service 'Ledger6002.Logic.Ledger6002_Process_File(9eb6993c-87d0-7bf0-b0bf-e1f684000af2)'.
The service instance will remain suspended until administratively resumed or terminated.
If resumed the instance will continue from its last persisted state and may re-throw the same unexpected exception.
InstanceId: 216e4bac-0f22-4e06-9e61-2ef46051c991
Shape name: msg_Email
ShapeId: e7ce3f54-0558-4756-a7e4-e3800721178f
Exception thrown from: segment 1, progress 55
Inner exception: There is an error in XML document (1, 1).
Exception type: InvalidOperationException
Source: System.Xml
Target Site: System.Object Deserialize(System.Xml.XmlReader, System.String, System.Xml.Serialization.XmlDeserializationEvents)
The following is a stack trace that identifies the location where the exception occured
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
at System.Xml.Serialization.XmlSerializer.Deserialize(TextReader textReader)
at Microsoft.XLANGs.Core.Value.GetObject(Type t)
at Microsoft.XLANGs.Core.Value._prepareForWrite(PreferredValueRepresentation pvr)
at Microsoft.XLANGs.Core.ValueTable.PrepareForWrite(ValueToken& vt, PreferredValueRepresentation pvr)
at Microsoft.XLANGs.Core.Part.PrepareForWrite(PreferredValueRepresentation pvr)
at Microsoft.XLANGs.Core.Part.SetPartProperty(Type propType, Object val)
at Microsoft.XLANGs.Core.Part.SetPropertyValue(Type propType, Object val)
at Ledger6002.Logic.Ledger6002_Process_File.segment1(StopConditions stopOn)
at Microsoft.XLANGs.Core.SegmentScheduler.RunASegment(Segment s, StopConditions stopCond, Exception& exp)
Additional error information:
Data at the root level is invalid. Line 1, position 1.
Exception type: XmlException
Source: System.Xml
Target Site: Void Throw(System.Exception)
The following is a stack trace that identifies the location where the exception occured
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace()
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlTextReader.Read()
at System.Xml.XmlReader.MoveToContent()
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderObject.Read2_anyType()
msg_email 是一个多部分消息,有两个部分:bodyPart 和 attachmentPart,都定义为 RawString 自定义类。
什么可能导致此错误?我需要使用 MIME/编码器的管道吗?
我现在在另一个客户处,尝试回答 2017 年的问题(但使用编排而不是管道):如何设置附件名称以在 Outlook 中正确显示
当我注释掉设置 contentType 的两行时,我收到一封电子邮件,但问题与上面 2017 年帖子中提到的问题相同。
解决方案
你至少错过了两件事:
- 使用 SMTP.MessagePartsAttachments 设置并将其设置为“2”
- 使用 SMTP.EmailBodyTextCharset 并将其设置为“UTF-8”
推荐阅读
- matplotlib - 在 2Y 轴上堆叠多个图
- python - 使用 facebook api 从 facebook 收集 Like、Share、评论
- c# - 如何对列表中的 2 个不同规则进行排序
- symfony - 创建捆绑包时使用实体的良好做法
- logging - 阻止 WLP 将 System.out 写入 messages.log
- c++ - 在基类和派生类之间正确设置函数的返回
- excel - 访问共享邮箱收件箱中文件夹子文件夹的详细信息
- c# - 如何在我的业务逻辑层管理单一性?
- flutter - 使用地理定位器的当前位置
- java - 如何测试此存储库方法 makeAddBuildingApiCall 和 addBuildingDetails