This is a basic step. To accomplish this, you have to define the message context property of the output message.
The message context is a container for various properties that are used by BizTalk Server when processing the document. Each property in the Message Context is composed of three things, a name, a namespace, and a value.
In orchestration:
- Double-click in the Message Assignment shape (of the output message) and type:
msgOutput(FILE.ReceivedFileName) = “out_” + msgInput(FILE.ReceivedFileName);

In the BizTalk Server Administration Console:
- Set Send port:
- Port type: Static One-Way
- Transport: FILE
- DestinationFolder: (To OUT folder)
- FILENAME: %SourceFileName%
- Send pipeline: XMLTransmit

Test application:
- Create two folders (IN and OUT), configure the receive location to get from the IN folder and the send port send to the OUT folder
Source Code/Download
THIS COMPONENT IS PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND.
You can download the source code from GitHub here:
Hope you find this helpful! So, if you liked the content or found it useful and want to help me write more, you can help us buy a Star Wars Lego for my son!
Hi,There are others Message Context Properties associated with other adapters, this is one example: msg(WSS.Filename) = "file.txt";
Hi,
what if when my request message is coming from webservice using SOAP adapter?
Hi Dhiraj,
When you receive a message through webservice using SOAP adapter, WCF adapter or even for example HTTP adapter… your don’t have the property FILE.ReceivedFileName defined in the receive message, so you need to define the output file name: static, perhaps based on some content of the message or programatic.
msgOutput(FILE.ReceivedFileName) = “out_file.xml”;
msgOutput(FILE.ReceivedFileName) = “out_” + msgInput.MyAttribute + “.xml”;
msgOutput(FILE.ReceivedFileName) = “out_” + System.DateTime.Now + “.xml”;
Another option is: you can create a custom component for the receive pipeline that promotes the FILE.ReceivedFileName in the received message, again based on some content of the message, static or programatic.
Hi Sandro,
Thanks for the article! I have a question:
Background: I’m using a dynamic FTP send port (because I need to alter the directory and some other parameters each transaction, programmatically). I’m using a MessageAssignment shape to specify the FTP parameters.
But in addition to this, I also need to output a very specific file name. I have already tried this method of using – OutputMsg(FILE.ReceivedFileName) = “SampleOutputFileName.txt”;
It does not work because there is no way for me to specify the macro %SourceFileName% anywhere.
Question: Do you know how I would be able to manipulate the output file name in a dynamic FTP send port?
Thanks in advance!