BizTalk - Setting email contentType causes error: There is an error in XML document (1, 1)

白昼怎懂夜的黑 提交于 2021-01-07 01:37:49

问题


When I try to set the Microsoft.XLANGs.BaseTypes.ContentType in a BizTalk orchestration, I get an XML error (regardless of whether I use "text/plain" or "text/xml". I'm using a dynamic send port with the PassThru pipeline.

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";

Causes this error:

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 is a multipart message, with two parts: bodyPart and attachmentPart, both defined as a RawString custom class.

What could be causing this error? Do I need a pipeline that uses the MIME/Encoder?

I'm now at a different client, trying a response to a 2017 question (but using an orchestration instead of a pipeline): How Set Attachment Name to Show Properly in Outlook

When I comment out the two lines that set the contentType, I get an email, but same problem as referenced in the 2017 post above.


回答1:


You're missing at least 2 things:

  • Use the SMTP.MessagePartsAttachments setting and set it on "2"
  • Use the SMTP.EmailBodyTextCharset and set it on "UTF-8"


来源:https://stackoverflow.com/questions/65480570/biztalk-setting-email-contenttype-causes-error-there-is-an-error-in-xml-docum

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!