主体部分在biztalk动态SMTP发送端口中作为附件发送

时间:2019-07-04 05:08:53

标签: c# email dynamic smtp biztalk

电子邮件正在使用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;

预期结果:电子邮件不应包含正文作为附件。

1 个答案:

答案 0 :(得分:0)

在发送端口管道中添加“ MIME / SMIME编码器”管道组件,并将“发送正文部分作为附件”属性设置为“ False”。该enter image description here应该可以解决问题。