Joshi.Utils.Imap.Imap.ParseEnvelope C# (CSharp) 메소드

ParseEnvelope() 개인적인 메소드

private ParseEnvelope ( string &sBodyStruct, ArrayList asAttrs ) : bool
sBodyStruct string
asAttrs System.Collections.ArrayList
리턴 bool
        bool ParseEnvelope(ref string sBodyStruct,
            ArrayList asAttrs)
        {
            // remove any spaces at the beginning and the end
            sBodyStruct = sBodyStruct.Trim();

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

            // look for '(' character
            if (!FindAndRemove(ref sBodyStruct, '('))
                return false;

            string sTemp = "";
            // Date
            if (!ParseQuotedString( ref sBodyStruct, ref sTemp ))
            {
                Log( LogTypeEnum.ERROR, "Invalid Message Envelope Date.");
                return false;
            }
            if (sTemp.Length > 0)
            {
                asAttrs.Add(IMAP_HEADER_DATE_TAG );
                asAttrs.Add(sTemp);
            }

            // Subject
            if (!ParseQuotedString( ref sBodyStruct, ref sTemp ))
            {
                Log(LogTypeEnum.ERROR, "Invalid Message Envelope Subject.");
                return false;
            }
            if (sTemp.Length > 0)
            {
                asAttrs.Add(IMAP_HEADER_SUBJECT_TAG);
                asAttrs.Add(sTemp );
            }

            // From
            if (!ParseAddressList(ref sBodyStruct, ref sTemp ))
            {
                Log(LogTypeEnum.IMAP, "Invalid Message Envelope From.");
                return false;
            }
            if (sTemp.Length > 0)
            {
                asAttrs.Add(IMAP_HEADER_FROM_TAG);
                asAttrs.Add(sTemp);
            }

            // Sender
            if (!ParseAddressList(ref sBodyStruct, ref sTemp ))
            {
                Log(LogTypeEnum.ERROR, "Invalid Message Envelope Sender.");
                return false;
            }
            if (sTemp.Length > 0)
            {
                asAttrs.Add(IMAP_HEADER_SENDER_TAG);
                asAttrs.Add(sTemp);
            }

            // ReplyTo
            if (!ParseAddressList(ref sBodyStruct, ref sTemp ))
            {
                Log(LogTypeEnum.ERROR, "Invalid Message Envelope Reply-To.");
                return false;
            }
            if (sTemp.Length > 0)
            {
                asAttrs.Add(IMAP_HEADER_REPLY_TO_TAG);
                asAttrs.Add(sTemp);
            }

            // To
            if (!ParseAddressList(ref sBodyStruct, ref sTemp ))
            {
                Log(LogTypeEnum.IMAP, "Invalid Message Envelope To.");
                return false;
            }
            if (sTemp.Length > 0)
            {
                asAttrs.Add(IMAP_HEADER_TO_TAG);
                asAttrs.Add(sTemp);
            }

            // Cc
            if (!ParseAddressList(ref sBodyStruct, ref sTemp ))
            {
                Log(LogTypeEnum.ERROR, "Invalid Message Envelope CC.");
                return false;
            }
            if (sTemp.Length > 0)
            {
                asAttrs.Add(IMAP_HEADER_CC_TAG);
                asAttrs.Add(sTemp);
            }

            // Bcc
            if (!ParseAddressList(ref sBodyStruct, ref sTemp ))
            {
                Log(LogTypeEnum.ERROR, "Invalid Message Envelope BCC.");
                return false;
            }
            if (sTemp.Length > 0)
            {
                asAttrs.Add(IMAP_HEADER_BCC_TAG);
                asAttrs.Add(sTemp);
            }

            // In-Reply-To
            if (!ParseQuotedString( ref sBodyStruct, ref sTemp ))
            {
                Log(LogTypeEnum.ERROR, "Invalid Message Envelope In-Reply-To.");
                return false;
            }
            if (sTemp.Length > 0)
            {
                asAttrs.Add(IMAP_HEADER_IN_REPLY_TO_TAG);
                asAttrs.Add(sTemp);
            }

            // Message Id
            if (!ParseQuotedString( ref sBodyStruct, ref sTemp ))
            {
                Log(LogTypeEnum.ERROR, "Invalid Message Envelope Message Id.");
                return false;
            }
            if (sTemp.Length > 0)
            {
                asAttrs.Add(IMAP_MESSAGE_ID);
                asAttrs.Add(sTemp);
            }

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