0

Email is getting Body in attachment along with attachment using biztalk SMTP dynamic send port.

Using C# helper class as:

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

In Message Assignment shape in Orchestration:

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;

Expected Result : Email should not have the body as attachment.

Code_ABC
  • 27
  • 1
  • 6
  • 1
    why are you using 2 message parts? msgSendEmail(SMTP.MessagePartsAttachments) = 2; – Ed Bangga Jul 04 '19 at 06:49
  • as I need to send Attachments in Email. – Code_ABC Jul 09 '19 at 07:34
  • seems you only have 1 attachment. so it should be msgSendEmail(SMTP.MessagePartsAttachments) = 1; – Ed Bangga Jul 09 '19 at 07:37
  • @Code_ABC I've made a pretty extensive answer in an older question related to attachments in dynamic send ports which could help you out. Check it out here: https://stackoverflow.com/questions/43917794/how-set-attachment-name-to-show-properly-in-outlook/52426481#52426481 – r3verse Oct 14 '19 at 13:51

1 Answers1

0

Add a "MIME/SMIME encoder" pipeline component to your send port pipeline and set "send body part as attachment" property to "False". Thatenter image description here should do the trick.

Himanshu
  • 13
  • 4