Custom Party Resolution BizTalk Server 2006: Resolve party by POP3.From and square brackets

Posted: March 28, 2009  |  Categories: BizTalk Uncategorized

Recently I wrote a BizTalk Server 2006 custom pipeline component to resolve a custom party on the POP3.From context value when an email was received. I was surprised to find some unusual behaviour if the POP3.From context value contained square brackets like “HEWHOCARES [WORLD]” < >. I describe the behaviour and why it occurs below because it took me by surprise.

The base example for the custom pipeline component is based on . The code fragment below shows the important changes;

/// This function gets called after the entire stream of the message has been read, guaranteeing that all promoted properties
        /// from the message have been populated to the message context.
        /// </summary>
        internal void EndOfStream()
            string FromEmail = null;
            BizTalkParty party;

            //obtain the FromEmail string from the message
            FromEmail = (string)mBaseMessage.Context.Read(“From”, “”);

            if (FromEmail != null)
                PartyResolver pr = new PartyResolver();
                party = pr.GetPartyFromAlias(“FromEmail”, “FromEmailName”, FromEmail);

                mBaseMessage.Context.Promote(“SourcePartyID”, “”, party.SID);
                mBaseMessage.Context.Promote(“PartyName”, “”, party.Name);

I set up my party like; parties

On testing this pipeline component with an email from “HEWHOCARES” < >   it resolves the party to ThePeopleWhoCare. Now if I change the party value to “HEWHOCARES [WORLD]” < > and send an email from the same email address then it resolves to Guest not ThePeopleWhocare. What is going on? If you dig a bit further you find that to resolve the party this stored procedure is used;

USE [BizTalkMgmtDb]
/****** Object:  StoredProcedure [dbo].[admsvr_GetPartyByAliasNameValue]    Script Date: 03/24/2009 21:16:03 ******/
ALTER PROCEDURE [dbo].[admsvr_GetPartyByAliasNameValue]
@nvcAliasName nvarchar(256),
@nvcAliasQualifier nvarchar(64),
@nvcAliasValue nvarchar(256),
@nvcSID nvarchar(256) OUTPUT,
@nvcName nvarchar(256) OUTPUT
SELECT      @nvcSID = bts_party.nvcSID,
            @nvcName = bts_party.nvcName
FROM bts_party, bts_party_alias
WHERE       UPPER(bts_party_alias.nvcName) = UPPER(@nvcAliasName) AND
            UPPER(bts_party_alias.nvcQualifier) = UPPER(@nvcAliasQualifier) AND
           bts_party_alias.nvcValue LIKE @nvcAliasValue  AND
           bts_party_alias.nPartyID = bts_party.nID

The WHERE clause uses a LIKE statement for the criteria based on the passed POP3.FROM context value.  [] in a like statement is evaluated as any single character within the specified range. Thus in our case we try find a party with an FromEmail value of “HEWHOCARES W” < > (or where W” is O”, R”, L” or D”). Indeed if I now change the party value to “HEWHOCARES W” < > then “HEWHOCARES [WORLD]” < > resolves to ThePeopleWhoCare once again.

BizTalk Server

Over 650+ customers across
30+ countries depend on BizTalk360

Learn More

Operate efficiently with enterprise-grade Azure monitoring,
tracing, remediation & governance in one platform

Learn More

Back to Top