Re: Send all Incomming files as an mail attachment

Home Page Forums BizTalk 2004 – BizTalk 2010 Send all Incomming files as an mail attachment Re: Send all Incomming files as an mail attachment

#25597

A sequential convoy will basically just receive messages one after another. You can do whatever you like with these messages.
One pattern is to aggregate multiple messages into a single message as you describe above.
The pattern you need is to create a multi-part message with each new file added as an extra part to the message. The SMTP adapter will take this message and use the body part as the email body and additional parts as attachments. You do not need to use the MIME/SMIME encoder unless you wish to encrypt the mail.

You can use this code to create the multi-part message:

public class MessageHelper
{
public static void AddAttachment(XLANGMessage destination, XLANGMessage attachment, string filename)
{
try
{
int
count = destination.Count;
destination.AddPart(attachment[0],
string.Format(“Attachment_{0}”, count));
destination[count].SetPartProperty(
typeof(MIME.FileName), filename);
}
finally
{
//decrement reference count
destination.Dispose();
attachment.Dispose();
}
}
}

In your orchestration, create an new message (OutputEmailMessage) with the email body, then in your receive loop add each incoming message

MessageHelper.AddAttachment(OutputEmailMessage, IncomingFileMessage, IncomingFileMessage(FILE.ReceivedFilename));

Send the OutputEmailMessage to your SMTP adapter, ensure you set Send All Attachments property.