Home Page › Forums › BizTalk 2004 – BizTalk 2010 › Send all Incomming files as an mail attachment
- This topic has 3 replies, 1 voice, and was last updated 9 years, 2 months ago by
community-content.
-
AuthorPosts
-
-
August 11, 2010 at 4:38 AM #25596
Hi,
The requirement is, I have a FTP folder. My receive port will pull the files in every 30 mins. Then from the send port I need to send a mail with attachement of all those incomming files as it is.
My plan is I have created a receive port and i set the pooling Interval. Then I created the Send port and configure the filter as BTS.receive port name = name of the receive port I have created. I configured the SMTP port. I have used a send pipeline file where i configured the MIME/SMIME encoder in the ecode phase, which will attach the files with the mail.
But the problem is, I am getting different mails per each files received in receive folder. The requirement is, all the files in receive folder should be attached in a single mail.
I am having only one folder. Where I need to fetch all the files in a certain time interval and send those files as attachement of a mail. And all the incomming files should be as it is in the attachement.
I think I should use sequential convoy. I dont know much about this and as far as I know the convoy will join all the XML files to a single XML, which I dont need.
Please propose me a solution.
Thanks In Advance.
-
August 11, 2010 at 5:13 AM #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.
-
August 17, 2010 at 3:06 AM #25653
Hi Greg,
As you described aboove. I dont want to aggregate multiple messages into a single message. Just to add all the incomming messages as it is to a zip file. I am using one custom pipeline to for zipping at the send port. At the begening i thought of using multi part messages. but i know multipart messages will aggregate all incomming messages to a single message, which i dont want. And all the incomming messages are of same message type but contains different error messages.
Thanks for your reply. And waiting for a suggestion on this.
Regards,
Ram
-
August 17, 2010 at 10:10 PM #25658
A BizTalk messages are effectively multipart messages. The have the following structure
Message
MessagePart: data
MessagePart: data
MessagePart: dataThe data elements are totally separate. You can have a multipart message with Xml in the first part, an image file in the second part and a flat file stream in the third part. These parts are NOT aggregated into a single Xml.
In your orchestration you create a multipart message as I described above, then in your custom pipeline component you can create a new message part for your zip stream. Then iterate over the attachment message parts add them to your zip stream and remove them from the message, finally add you zip stream message part to the message.
-
-
-
-
AuthorPosts
- The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.