Пример #1
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);
 }
Пример #2
0
        public MailMessageEx Top(int messageId, int lineCount)
        {
            if (messageId < 1)
            {
                throw new ArgumentOutOfRangeException("messageId");
            }

            if (lineCount < 0)
            {
                throw new ArgumentOutOfRangeException("lineCount");
            }

            RetrResponse response;

            using (TopCommand command = new TopCommand(_clientStream, messageId, lineCount))
            {
                response = ExecuteCommand <RetrResponse, TopCommand>(command);
            }

            MimeReader    reader  = new MimeReader(response.MessageLines);
            MimeEntity    entity  = reader.CreateMimeEntity();
            MailMessageEx message = entity.ToMailMessageEx();

            message.Octets        = response.Octets;
            message.MessageNumber = messageId;
            return(entity.ToMailMessageEx());
        }
Пример #3
0
        /// <summary>
        /// Processes mime specific headers.
        /// </summary>
        /// <returns>A mime entity with mime specific headers parsed.</returns>
        private void ProcessHeaders()
        {
            foreach (string key in _entity.Headers.AllKeys)
            {
                switch (key)
                {
                case "content-description":
                    _entity.ContentDescription = _entity.Headers[key];
                    break;

                case "content-disposition":
                    _entity.ContentDisposition = new ContentDisposition(_entity.Headers[key]);
                    break;

                case "content-id":
                    _entity.ContentId = _entity.Headers[key];
                    break;

                case "content-transfer-encoding":
                    _entity.TransferEncoding        = _entity.Headers[key];
                    _entity.ContentTransferEncoding = MimeReader.GetTransferEncoding(_entity.Headers[key]);
                    break;

                case "content-type":
                    _entity.SetContentType(MimeReader.GetContentType(_entity.Headers[key]));
                    break;

                case "mime-version":
                    _entity.MimeVersion = _entity.Headers[key];
                    break;
                }
            }
        }
Пример #4
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;
     _encodedMessage = new StringBuilder();
 }
Пример #5
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());
        }
Пример #6
0
        /// <summary>
        /// Retrs the specified message.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <returns>A MimeEntity for the requested Pop3 Mail Item.</returns>
        public MimeEntity RetrMimeEntity(Pop3ListItem item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            if (item.MessageId < 1)
            {
                throw new ArgumentOutOfRangeException("item.MessageId");
            }

            RetrResponse response;

            using (RetrCommand command = new RetrCommand(_clientStream, item.MessageId))
            {
                response = ExecuteCommand <RetrResponse, RetrCommand>(command);
            }

            MimeReader reader = new MimeReader(response.MessageLines);

            return(reader.CreateMimeEntity());
        }