部分在构造块的末尾包含空值

部分在构造块的末尾包含空值

本文介绍了BizTalk SMTP 消息“msg_Email"的“PartAttachment"部分在构造块的末尾包含空值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题的快速摘要 - 当我将 RawString 设置为文本时,会发送带有附件的电子邮件并正确命名.当我将附件设置为 RawString 消息时,我收到错误消息消息 'msg_Email' 的部分 'PartAttachment' 在构造块的末尾包含一个空值."

Quick summary of issue - when I set the RawString to text, the email with attachment is sent and properly named. When I set the attachment to a RawString message, I get the error "The part 'PartAttachment' of message 'msg_Email' contained a null value at the end of the construct block."

我创建了自己的 RawString 类,我以前使用过.编排通过直通管道接收 CSV 文件.根据我找到的一些文档,我收到了一个 XmlDocument,在下一个形状中,我构造了 RawString,如下所示:

I have created my own RawString class which I have used before. The orchestration receives a CSV file via a pass-thru pipline. Following some documentation I found, I receive a XmlDocument, and in the next shape, I construct the RawString as follows:

msg_Raw_String.MessagePart_1 = msg_Ledger6002_File_XmlDoc;

但是,如果我在 RawString 中设置为虚拟文本,则会发送带有附件的电子邮件(附件只是一个文本文件,其值如下:

However if I set the to dummy text in RawString, the email with attachment is sent (the attachment is just a text file with the value below:

   msg_Email.PartAttachment = new XXXLedger6002.Component.RawString("Test Text");

消息分配中的完整代码:

Full code in message assignment:

msg_Email.BodyPart = new XXXLedger6002.Component.RawString("See attached email. Method 2 Dynamic");

// Force some value to make sure it is not null
//msg_Email.PartAttachment = new Ledger6002.Component.RawString("Test Text");
// Tried both of these, same error:
//msg_Email.PartAttachment = msg_Ledger6002_File_XmlDoc;
msg_Email.PartAttachment = msg_Raw_String.MessagePart_1;
// syntax doesn't allow this:
// msg_Email.PartAttachment = msg_Raw_String;


// 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.PartAttachment(MIME.FileName) =  attachmentName;

//msg_Email.BodyPart(Microsoft.XLANGs.BaseTypes.ContentType) = "text/plain";//
//msg_Email.AttachmentPart(Microsoft.XLANGs.BaseTypes.ContentType) = "text/plain";

msg_Email(SMTP.Subject) = "Ledger6002 File";
msg_Email(SMTP.SMTPTo) = msg_Config_Email.smtpToEmail;
msg_Email(SMTP.From) = msg_Config_Email.smtpFromEmail;
msg_Email(SMTP.SMTPAuthenticate) = 0;   // do not authenticate to SMTP server
msg_Email(SMTP.SMTPHost) = msg_Config_Email.smptHostName;

// msg_Email(SMTP.EmailBodyText) = "UTF-8";
msg_Email(SMTP.EmailBodyTextCharset)  = "UTF-8";
msg_Email(SMTP.MessagePartsAttachments) = 2;

// No email generated with comment out line, trying same without mailto:
SMTP_Dyn_Email(Microsoft.XLANGs.BaseTypes.Address) = "mailto:" + msg_Config_Email.smtpToEmail;

SMTP_Dyn_Email(Microsoft.XLANGs.BaseTypes.TransportType) = "SMTP";

错误:

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: ecaa7ed2-04c1-46b9-b845-cf3211b83387
Shape name: Send_Dyn_Email
ShapeId: 4ada59c3-367e-40b4-babc-d0d9999feb77
Exception thrown from: segment 1, progress 60
Inner exception: The part 'PartAttachment' of message 'msg_Email' contained a null value at the end of the construct block.

Exception type: NullPartException
Source: Microsoft.XLANGs.Engine
Target Site: System.IO.Stream Persist(System.String ByRef, Boolean)
The following is a stack trace that identifies the location where the exception occured

   at Microsoft.XLANGs.Core.CustomFormattedPart.Persist(String& encoding, Boolean wantEncoding)
   at Microsoft.BizTalk.XLANGs.BTXEngine.BTXXlangStore.StagePartData(Part part)
   at Microsoft.BizTalk.XLANGs.BTXEngine.BTXXlangStore.PrepareMessage(XLANGMessage msg, IList promoteProps, IList toPromote)
   at Microsoft.BizTalk.XLANGs.BTXEngine.BTXXlangStore.WriteMessageState(IBTPEPInfoLookup pepLookup, Guid portId, XLANGMessage msg, Segment seg, String opname, String url, IList promoteProps, Boolean track, IList toPromote)
   at Microsoft.BizTalk.XLANGs.BTXEngine.BTXLogicalPortBinding.SendMessage(XLANGMessage msg, XlangStore store, Segment seg, OperationInfo op, IList additionalProps, IList toPromote, Boolean ignoreRoutingFailure)
   at Microsoft.BizTalk.XLANGs.BTXEngine.BTXPortBase.SendMessage(Int32 iOperation, XLANGMessage msg, Correlation[] initCorrelations, Correlation[] followCorrelations, Context cxt, Segment seg, ActivityFlags flags)
   at Ledger6002.Logic.Ledger6002_Process_File.segment1(StopConditions stopOn)
   at Microsoft.XLANGs.Core.SegmentScheduler.RunASegment(Segment s, StopConditions stopCond, Exception& exp)

推荐答案

以下是似乎可行的解决方法.

The following is a get-around that seems to work.

msg_Email.PartAttachment = new SBA.Ledger6002.Component.RawString(
                                msg_Raw_String.MessagePart_1.ToString());

如果有人能解释为什么我不能将它设置为 msg_Raw_String.MessagePart_1,我很想知道.

If anybody can explain why I just can't set it to msg_Raw_String.MessagePart_1, I would love to know.

这篇关于BizTalk SMTP 消息“msg_Email"的“PartAttachment"部分在构造块的末尾包含空值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 11:06