3

I'm attempting to send a message through a BizTalk SMTP Send Port. Specifically, I am sending a message through a "specify-later" port of an orchestration. My goal is to attach the message body to the sent email with an attachment filename of my choosing.

However, no matter what I try the attachment name remains "body.csv"

I have tried:

  1. Multipart message with a single part + set MIME.FileName on this part.
  2. Multipart message with two parts (both attached) + set MIME.FileName on both parts (the non-body part correctly had the attachment name, the body part did not).
  3. Standard message + set MIME.FileName on the message.

I have tried this with all configurations on the SMTP adapter of "Attach only body part" and "Attach all parts" and none worked.

Currently I have "Attach only body part" and some fixed text (configured on the send port) for the email content.

I have read that some have used the MIME Encoder pipeline in past versions of BizTalk, but apparently this is unnecessary with the SMTP Adapter. Others use custom pipeline components to set MIME.FileName which is where I'm heading, but seems unnecessary if the MIME.FileName is already set in my orchestration.

Am I missing something fundamental here for this relatively simple problem?

2 Answers 2

3

You can do this in an orchestration within a message assignment shape. Using a multipart, message would look like this:

Message.part(MIME.FileName) = "your file.name";

1
  • This might have worked with older versions of Outlook, but not Outlook 365 and newer versions of Outlook. Dec 28, 2020 at 16:18
2

The second suppose to work. Try using this code (that works for me) from an helper:

public static void SetFileName(string emailMessage,XLANGMessage message)
{
    Byte[] b = GetBytes(emailMessage);
    MemoryStream stream = new MemoryStream(b);
    IStreamFactory factory = new BinaryStreamFactory(stream);
    string partName = FileName + "." + FileType;
    message.AddPart(factory, partName);
    XLANGPart part = message[partName];
    part.SetPartProperty(typeof(MIME.FileName), partName);
}

static byte[] GetBytes(string str)
{
    byte[] bytes = new byte[str.Length * sizeof(char)];
    System.Buffer.BlockCopy(str.ToCharArray(), 0, bytes, 0, bytes.Length);
    return bytes;
}
2
  • 1
    Yeah I had to do something almost identical, which meant invoking my FF pipelines within the orchestration, adding the processed value as an additional part, and ensuring to use the body (which I set to generic text) as the email body (in the Compose tab of the SMTP adapter). Was never able to attach and rename the body part though, which sucks as now I'm sending a message that can only be sent as email. Aug 17, 2012 at 0:50
  • Your code is for an orchestration right, or is it a pipeline? May 10, 2017 at 13:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.