I’ve received a number of questions regarding a sample I posted a while ago: Arbitrary
Binary Attachments to Multi-Part Messages
; mostly related to issues when sending
the resulting messages through the SMTP adapter and not all attachments (or no attachments
at all) getting to the destination account.

I’ve found that usually, this is the result of setting the SMTP.MessagePartsAttachments
property to the wrong value. In the sample I posted alongside the article, I was setting
the property to 2. I didn’t give any explanation about it at the time, but
contrary to what it may intuitively appear, you don’t set this property to the number
of attachments (parts) you want to send alongside the message.If you attach 4 different
parts to the message, you don’t set the property to the value 4.

Instead, the value 2 means “Send all parts as attachments”, which is exactly the behavior
you want. For completeness sake, here’s what each possible value for this property
means (taken from the BizTalk
documentation
):

  • 0 – No BizTalk message parts will be used as attachments.

  • 1- The BizTalk message body part is sent as an e-mail attachment. In this case, the EmailBodyFile or EmailBodyText properties
    should be specified. If neither of these properties are specified, the BizTalk message
    body part is sent as the e-mail body instead of as an attachment.

  • 2 – All parts are sent as attachments. However, if EmailBodyText or EmailBodyFile are
    not specified, then the BizTalk message body part is sent as the e-mail body and other
    parts are sent as attachments.
  • Technorati
    tags: BizTalk
    Server