Joshi.Utils.Imap.Imap.ParseAddress C# (CSharp) Method

ParseAddress() private method

Parse one address and format the string
private ParseAddress ( string &sBodyStruct, string &sString ) : bool
sBodyStruct string body structure
sString string address
return bool
        bool ParseAddress(ref string sBodyStruct, ref string sString)
        {
            sString = "";

            // remove any spaces at the beginning and the end
            sBodyStruct = sBodyStruct.Trim();

            // check if this is NIL
            if (IsNilString(ref sBodyStruct))
                return true;

            // remove the opening paranthesis
            if (!FindAndRemove( ref sBodyStruct, '('))
                return false;

            string sPersonal = "";
            string sEmailId = "";
            string sEmailDomain = "";
            string sTemp = "";

            // Personal Name
            if (!ParseQuotedString( ref sBodyStruct, ref sPersonal ))
            {
                Log(LogTypeEnum.ERROR, "Failed getting the Personal Name.");
                return false;
            }
            // At Domain List (Right now, don't know what to do with this)
            if (!ParseQuotedString( ref sBodyStruct, ref sTemp ))
            {
                Log (LogTypeEnum.ERROR, "Failed getting the Domain List.");
                return false;
            }
            // Email Id
            if (!ParseQuotedString( ref sBodyStruct, ref sEmailId ))
            {
                Log(LogTypeEnum.ERROR, "Failed getting the Email Id.");
                return false;
            }
            // Email Domain
            if (!ParseQuotedString( ref sBodyStruct, ref sEmailDomain ))
            {
                Log(LogTypeEnum.ERROR, "Failed getting the Email Domain.");
                return false;
            }

            if (sEmailId.Length > 0)
            {
                if (sPersonal.Length > 0)
                {
                    if (sEmailDomain.Length > 0)
                    {
                        sString = sPersonal + " <" +
                                  sEmailId  + "@" +
                                  sEmailDomain + ">";
                    }
                    else
                    {
                        sString = sPersonal + " <" +
                                  sEmailId + ">";
                    }
                }
                else
                {
                    if (sEmailDomain.Length > 0)
                    {
                        sString = sEmailId + "@" + sEmailDomain;
                    }
                    else
                    {
                        sString = sEmailId;
                    }
                }
            }

            // remove the closing paranthesis
            return FindAndRemove(ref sBodyStruct, ')');
        }