A e-mail content type with all of its sub-information.
示例#1
0
        /// <summary>
        /// Parse the e-mail from the given text lines.
        /// </summary>
        /// <param name="MailText">The E-Mail as an enumeration of strings.</param>
        public EMailBodypart(IEnumerable <String> MailText)
            : base(MailText, header => header.ToLower().StartsWith("content"))
        {
            if (ContentType == null)
            {
                ContentType = new MailContentType(this, GetEMailHeader("Content-Type"));
            }

            if (ContentType.Text.Contains("boundary="))
            {
                var MIMEBoundaryCheck    = "--" + ContentType.MIMEBoundary;
                var MIMEBoundaryCheckEnd = "--" + ContentType.MIMEBoundary + "--";

                var ListOfList = new List <List <String> >();
                var List       = new List <String>();

                foreach (var line in MailBody)
                {
                    if (line == MIMEBoundaryCheck ||
                        line == MIMEBoundaryCheckEnd)
                    {
                        ListOfList.Add(List);
                        List = new List <String>();
                    }

                    else
                    {
                        List.Add(line);
                    }
                }

                this._MailBody.Clear();
                this._MailBody.AddRange(ListOfList[0]);
                _NestedBodyparts = ListOfList.Skip(1).Select(list => new EMailBodypart(list)).ToList();
            }

            else
            {
                //this._MailBody.Clear();
                //this._MailBody.AddRange(MailBody);
                _NestedBodyparts = new EMailBodypart[0];
            }
        }
示例#2
0
        /// <summary>
        /// Parse the e-mail from the given text lines.
        /// </summary>
        /// <param name="MailText">The E-Mail as an enumeration of strings.</param>
        public EMailBodypart(IEnumerable<String> MailText)
            : base(MailText, header => header.ToLower().StartsWith("content"))
        {
            if (ContentType == null)
                ContentType = new MailContentType(this, GetEMailHeader("Content-Type"));

            if (ContentType.Text.Contains("boundary="))
            {

                var MIMEBoundaryCheck    = "--" + ContentType.MIMEBoundary;
                var MIMEBoundaryCheckEnd = "--" + ContentType.MIMEBoundary + "--";

                var ListOfList = new List<List<String>>();
                var List       = new List<String>();

                foreach (var line in MailBody)
                {

                    if (line == MIMEBoundaryCheck ||
                        line == MIMEBoundaryCheckEnd)
                    {
                        ListOfList.Add(List);
                        List = new List<String>();
                    }

                    else
                        List.Add(line);

                }

                this._MailBody.Clear();
                this._MailBody.AddRange(ListOfList[0]);
                _NestedBodyparts = ListOfList.Skip(1).Select(list => new EMailBodypart(list)).ToList();

            }

            else
            {

                //this._MailBody.Clear();
                //this._MailBody.AddRange(MailBody);
                _NestedBodyparts = new EMailBodypart[0];

            }
        }