A recent post in the BizTalk forum, promted this entry.

The question was asked how you can put the MessageID into a dynamic send port. I suggested that you would put a rule SendPort(Microsoft.XLANGs.BaseTypes.Address)=@”file://c:\”+DocumentMsg(BTS.MessageID)+”.xml”;
The next post was telling that you can put the macro in the Expression, which is true, you can, but in the below demo, it shows why it would be preferable not to use the macros.
I created a simple orchestration that shows both ways, here is the orchestration:

Here is the expression rule:

Here is the results of running the file through the orchestration:

In HAT, which is where I think that the real value of which method you use lies, here is the message flow, notice the filename is right in the first page of the message flow for the first outbound message, and the macro %MessageID% is found on the second message:


The message that uses the macro, you have to click on the link to see the actual message ID of what was saved.


Again, here is the output:

At a recent client site, I used the macro initially, but then moved to the BTS.MessageID to ease in troubleshooting. Saving a couple of clicks when attempting to find the file really adds up after a while.