Example #1
0
        internal static List <RfcMailAddress> ParseMailAddresses(string input)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }
            List <RfcMailAddress> returner      = new List <RfcMailAddress>();
            IEnumerable <string>  mailAddresses = Utils.SplitStringWithCharNotInsideQuotes(input, ',');

            foreach (string mailAddress in mailAddresses)
            {
                returner.Add(RfcMailAddress.ParseMailAddress(mailAddress));
            }
            return(returner);
        }
Example #2
0
        private void ParseHeader(string headerName, string headerValue)
        {
            if (headerName == null)
            {
                throw new ArgumentNullException("headerName");
            }
            if (headerValue == null)
            {
                throw new ArgumentNullException("headerValue");
            }
            string text = headerName.ToUpperInvariant();

            switch (text)
            {
            case "TO":
                this.To = RfcMailAddress.ParseMailAddresses(headerValue);
                return;

            case "CC":
                this.Cc = RfcMailAddress.ParseMailAddresses(headerValue);
                return;

            case "BCC":
                this.Bcc = RfcMailAddress.ParseMailAddresses(headerValue);
                return;

            case "FROM":
                this.From = RfcMailAddress.ParseMailAddress(headerValue);
                return;

            case "REPLY-TO":
                this.ReplyTo = RfcMailAddress.ParseMailAddress(headerValue);
                return;

            case "SENDER":
                this.Sender = RfcMailAddress.ParseMailAddress(headerValue);
                return;

            case "KEYWORDS":
            {
                string[] keywordsTemp = headerValue.Split(new char[] { ',' });
                string[] array        = keywordsTemp;
                for (int i = 0; i < array.Length; i++)
                {
                    string keyword = array[i];
                    this.Keywords.Add(Utils.RemoveQuotesIfAny(keyword.Trim()));
                }
                return;
            }

            case "RECEIVED":
                this.Received.Add(new Received(headerValue.Trim()));
                return;

            case "IMPORTANCE":
                this.Importance = HeaderFieldParser.ParseImportance(headerValue.Trim());
                return;

            case "DISPOSITION-NOTIFICATION-TO":
                this.DispositionNotificationTo = RfcMailAddress.ParseMailAddresses(headerValue);
                return;

            case "MIME-VERSION":
                this.MimeVersion = headerValue.Trim();
                return;

            case "SUBJECT":
                this.Subject = Utils.Decode(headerValue);
                return;

            case "RETURN-PATH":
                this.ReturnPath = RfcMailAddress.ParseMailAddress(headerValue);
                return;

            case "MESSAGE-ID":
                this.MessageId = HeaderFieldParser.ParseId(headerValue);
                return;

            case "IN-REPLY-TO":
                this.InReplyTo = HeaderFieldParser.ParseMultipleIDs(headerValue);
                return;

            case "REFERENCES":
                this.References = HeaderFieldParser.ParseMultipleIDs(headerValue);
                return;

            case "DATE":
                this.Date     = headerValue.Trim();
                this.DateSent = Utils.StringToDate(headerValue);
                return;

            case "CONTENT-TRANSFER-ENCODING":
                this.ContentTransferEncoding = HeaderFieldParser.ParseContentTransferEncoding(headerValue.Trim());
                return;

            case "CONTENT-DESCRIPTION":
                this.ContentDescription = Utils.Decode(headerValue.Trim());
                return;

            case "CONTENT-TYPE":
                this.ContentType = HeaderFieldParser.ParseContentType(headerValue);
                return;

            case "CONTENT-DISPOSITION":
                this.ContentDisposition = HeaderFieldParser.ParseContentDisposition(headerValue);
                return;

            case "CONTENT-ID":
                this.ContentId = HeaderFieldParser.ParseId(headerValue);
                return;
            }
            this.UnknownHeaders.Add(headerName, headerValue);
        }