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):