Recently, somebody asked me how to access the MSMQ label from BizTalk, in order to access some information that is passed by its own C# application through the MSMQ label.
See issue described below.
----------------------------------
Below I give my problem, Please give me a good solution for me.
I have a C# application. It has an upload page. If user uploads a XML file,the C# application reads it and send this to MSMQ as a Message.
The code is below.

StreamReader sr = new StreamReader(Path); string str; str = sr.ReadToEnd(); System.Messaging.Message mm = new System.Messaging.Message(); mm.Formatter = new ActiveXMessageFormatter(); mm.Body = str.ToString(); mm.Label = UserID; mq.Send(mm);

I create a Orchestration with receive and send ports. The receive ports looks message from the MSMQ using MSMQ adapter. then I use schemas and maps to transfer the Message. After that, I use a file adapter for save the final message to a folder.

Every thing works fine. My problem is, I want to identify the User who uploads the file. In C# application I set the label for the message as USERID.

I want to save the name of the output file is [userid].xml.

I use %SourceFileName% and MsgOut(FILE.ReceivedFileName) to rename the output file. But how to get the userid from the C# application and set the file name. I cant able to access MSMQT.Label in Expression Editor. Because I use MSMQ adapter. Please give me a good solution.

The main problem is identify the user who uploads the file.
----------------------------------
The problem with the existing implementation of MSMQC lies in the MSMQPropertySchema.xsd file that seems to be incorrect.
This XSD schema must be updated so that the properties are marked as context properties. To do this, select each property and change the "Property Schema Base" property from default value (no value) to MessageContextPropertyBase. Once you do this, re-build and re-deploy the updated schema project, and you should be able to access these properties from your orchestration.
This is how the schema should look like

<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://schemas.microsoft.com/BizTalk/2003/msmqc-properties" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://schemas.microsoft.com/BizTalk/2003/msmqc-properties" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:annotation>
    <xs:appinfo>
      <b:schemaInfo schema_type="property" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" />
    </xs:appinfo>
  </xs:annotation>
  <xs:element name="AppSpecific" type="xs:int">
    <xs:annotation>
      <xs:appinfo>
        <b:fieldInfo propertyGuid="ec76abf6-1c10-4383-8182-635eaf20a790" propSchFieldBase="MessageContextPropertyBase" />
      </xs:appinfo>
    </xs:annotation>
  </xs:element>
  <xs:element name="ArrivedTime" type="xs:dateTime">
    <xs:annotation>
      <xs:appinfo>
        <b:fieldInfo propertyGuid="3d8ae2da-2f26-4422-a68a-67f005cf32c8" propSchFieldBase="MessageContextPropertyBase" />
      </xs:appinfo>
    </xs:annotation>
  </xs:element>
  <xs:element name="Authenticated" type="xs:boolean">
    <xs:annotation>
      <xs:appinfo>
        <b:fieldInfo propertyGuid="36e29190-e4cc-4e64-b181-4a63488ccd75" propSchFieldBase="MessageContextPropertyBase" />
      </xs:appinfo>
    </xs:annotation>
  </xs:element>
  <xs:element name="CorrelationId" type="xs:string">
    <xs:annotation>
      <xs:appinfo>
        <b:fieldInfo propertyGuid="d16e9d65-f742-4982-9c71-59089fa23b22" propSchFieldBase="MessageContextPropertyBase" />
      </xs:appinfo>
    </xs:annotation>
  </xs:element>
  <xs:element name="Id" type="xs:string">
    <xs:annotation>
      <xs:appinfo>
        <b:fieldInfo propertyGuid="c0e64a4d-8a6f-4b21-936c-5531abb255f4" propSchFieldBase="MessageContextPropertyBase" />
      </xs:appinfo>
    </xs:annotation>
  </xs:element>
  <xs:element name="Label" type="xs:string">
    <xs:annotation>
      <xs:appinfo>
        <b:fieldInfo propertyGuid="1ff2b7af-2dd8-4b38-8360-2373e5fb05f6" propSchFieldBase="MessageContextPropertyBase" />
      </xs:appinfo>
    </xs:annotation>
  </xs:element>
  <xs:element name="Priority" type="xs:int">
    <xs:annotation>
      <xs:appinfo>
        <b:fieldInfo propertyGuid="7f13d6b8-21c6-4914-9025-b91dc03c0b24" propSchFieldBase="MessageContextPropertyBase" />
      </xs:appinfo>
    </xs:annotation>
  </xs:element>
  <xs:element name="ResponseQueue" type="xs:string">
    <xs:annotation>
      <xs:appinfo>
        <b:fieldInfo propertyGuid="8cf607f9-165e-43c8-b730-07559d876b5c" propSchFieldBase="MessageContextPropertyBase" />
      </xs:appinfo>
    </xs:annotation>
  </xs:element>
  <xs:element name="SentTime" type="xs:dateTime">
    <xs:annotation>
      <xs:appinfo>
        <b:fieldInfo propertyGuid="603ffea4-4fd9-443c-9362-b662b8aacddb" propSchFieldBase="MessageContextPropertyBase" />
      </xs:appinfo>
    </xs:annotation>
  </xs:element>
  <xs:element name="SourceMachine" type="xs:string">
    <xs:annotation>
      <xs:appinfo>
        <b:fieldInfo propertyGuid="32fbdf7b-d19f-4e27-9b45-331810780eef" propSchFieldBase="MessageContextPropertyBase" />
      </xs:appinfo>
    </xs:annotation>
  </xs:element>
</xs:schema>