This class is responsible for parsing a string array of lines containing a MIME message.
Exemple #1
0
        /// <summary>
        /// Create MimeEntity from the given bytes
        /// </summary>
        /// <param name="bytes">The bytes to read</param>
        /// <returns>The parsed MimeEntity</returns>
        public static MimeEntity CreateFrom(byte[] bytes, bool throwOnInvalidContentType)
        {
            MimeReader reader = new MimeReader(bytes, throwOnInvalidContentType);
            MimeEntity entity = reader.CreateMimeEntity();

            return(entity);
        }
Exemple #2
0
 /// <summary>
 /// Sets the type of the content.
 /// </summary>
 /// <param name="contentType">Type of the content.</param>
 internal void SetContentType(ContentType contentType)
 {
     ContentType           = contentType;
     ContentType.MediaType = MimeReader.GetMediaType(contentType.MediaType);
     MediaMainType         = MimeReader.GetMediaMainType(contentType.MediaType);
     MediaSubType          = MimeReader.GetMediaSubType(contentType.MediaType);
 }
Exemple #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MimeEntity"/> class.
        /// </summary>
        public MimeEntity()
        {
            Children      = new List <MimeEntity>();
            Headers       = new NameValueCollection();
            ContentType   = MimeReader.GetContentType(string.Empty);
            Parent        = null;
            _contentBytes = new List <byte[]>();
            RawContent    = new MemoryStream();

            ContentTransferEncoding = System.Net.Mime.TransferEncoding.SevenBit; // RFC 2045 -- "Content-Transfer-Encoding: 7BIT" is assumed if the Content-Transfer-Encoding header field is not present.
        }
Exemple #4
0
        /// <summary>
        /// Adds the child entity.
        /// </summary>
        /// <param name="entity">The entity.</param>
        private void AddChildEntity(MimeEntity entity, Queue <byte[]> lines)
        {
            /*if (entity == null)
             * {
             *  return;
             * }
             *
             * if (lines == null)
             * {
             *  return;
             * }*/

            MimeReader reader      = new MimeReader(entity, lines, _throwOnInvalidContentType);
            MimeEntity childEntity = reader.CreateMimeEntity();

            entity.Children.Add(childEntity);

            byte[] innerBytes = childEntity.RawContent.ToArray();
            entity.RawContent.Write(innerBytes, 0, innerBytes.Length);
        }
Exemple #5
0
        /// <summary>
        /// Adds the child entity.
        /// </summary>
        /// <param name="entity">The entity.</param>
        private void AddChildEntity(MimeEntity entity, Queue<byte[]> lines)
        {
            /*if (entity == null)
            {
                return;
            }

            if (lines == null)
            {
                return;
            }*/

            MimeReader reader = new MimeReader(entity, lines, _throwOnInvalidContentType);
            MimeEntity childEntity = reader.CreateMimeEntity();
            entity.Children.Add(childEntity);

            byte[] innerBytes = childEntity.RawContent.ToArray();
            entity.RawContent.Write(innerBytes, 0, innerBytes.Length);
        }
Exemple #6
0
 /// <summary>
 /// Create MimeEntity from the given bytes
 /// </summary>
 /// <param name="bytes">The bytes to read</param>
 /// <returns>The parsed MimeEntity</returns>
 public static MimeEntity CreateFrom(byte[] bytes, bool throwOnInvalidContentType)
 {
     MimeReader reader = new MimeReader(bytes, throwOnInvalidContentType);
     MimeEntity entity = reader.CreateMimeEntity();
     return entity;
 }
Exemple #7
0
        /// <summary>
        /// Adds the child entity.
        /// </summary>
        /// <param name="entity">The entity.</param>
        private void AddChildEntity(MimeEntity entity, Queue<string> lines)
        {
            /*if (entity == null)
            {
                return;
            }

            if (lines == null)
            {
                return;
            }*/

            MimeReader reader = new MimeReader(entity, lines);
            entity.Children.Add(reader.CreateMimeEntity());
        }