电子邮件正在使用biztalk SMTP动态发送端口将正文与附件一起发送。
将C#助手类用作:
namespace OutputStringContent
{
[Serializable]
public class SMTPTestHelper
{
public static XLANGMessage AttachStreamToSmtpMessage(XLANGMessage xlangMsg, String strAttach)
{
byte[] memBuffer = Encoding.ASCII.GetBytes(strAttach);
IStreamFactory streamFactory = new BinaryStreamFactory(new MemoryStream(memBuffer));
xlangMsg.AddPart(streamFactory, "AttachedMessage");
xlangMsg["AttachedMessage"].SetPartProperty(typeof(Microsoft.XLANGs.BaseTypes.ContentType), "text/plain; name=text.txt");
return xlangMsg;
}
}
}
在业务流程中的消息分配形状中:
msgSendEmail.MessagePart_1 = new OutputStringContent.RawString(msgEmail.EmailBody); msgSendEmail.MessagePart_1(Microsoft.XLANGs.BaseTypes.ContentType) = "text/plain"; msgSendEmail = OutputStringContent.SMTPTestHelper.AttachStreamToSmtpMessage(msgSendEmail,msgEmail.EmailAttachements); msgSendEmail(SMTP.From) = msgEmail.EmailFrom; msgSendEmail(SMTP.SMTPTo) = msgEmail.EmailTo; msgSendEmail(SMTP.Subject) = msgEmail.EmailSubject; //msgSendEmail(SMTP.EmailBodyText) = msgEmail.EmailBody; msgSendEmail(SMTP.EmailBodyTextCharset) = "UTF-8"; msgSendEmail(SMTP.MessagePartsAttachments) = 2; msgSendEmail(SMTP.SMTPHost) = "smtp1.tucaas.com"; msgSendEmail(SMTP.SMTPAuthenticate) = 0; Port_SendEmail(Microsoft.XLANGs.BaseTypes.Address) = "mailto:"+msgEmail.EmailTo;
预期结果:电子邮件不应包含正文作为附件。