Exemple #1
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;
                }
            }
        }
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;
     _encodedMessage = new StringBuilder();
 }
Exemple #4
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());
        }
        private void messagesList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            // If there are no selected items, then disable the Delete button, clear the boxes, and return
            if (e.AddedItems.Count == 0)
            {
                deleteButton.IsEnabled = false;
                forwardButton.IsEnabled = false;
                rawView.Text = "";
                bodyView.Text = "";
                htmlViewTab.Visibility = Visibility.Hidden;
                tabControl.SelectedIndex = 0;
                return;
            }

            // Enable the delete and forward button
            deleteButton.IsEnabled = true;
            forwardButton.IsEnabled = true;

            // Load the file as an array of lines
            List<string> lines = new List<string>();
            string line;
            using (StreamReader sr = new StreamReader(((MessageEntry)e.AddedItems[0]).File))
                while ((line = sr.ReadLine()) != null)
                    lines.Add(line);
            string[] linesArray = lines.ToArray();

            // Set the raw message view
            rawView.Text = string.Join("\n", linesArray);

            try
            {
                // Load the MIME body
                MimeReader mr = new MimeReader(linesArray);
                MimeEntity me = mr.CreateMimeEntity();
                MailMessageEx mme = me.ToMailMessageEx();
                bodyView.Text = mme.Body;
                bodyViewTab.Visibility = Visibility.Visible;

                // If it is HTML, render it to the HTML view
                if (mme.IsBodyHtml)
                {
                    SetBrowserDocument(mme);
                    htmlViewTab.Visibility = Visibility.Visible;
                }
                else
                {
                    htmlViewTab.Visibility = Visibility.Hidden;
                    if (tabControl.SelectedItem == htmlViewTab)
                        tabControl.SelectedIndex = 1;
                }
            }
            catch
            {
                bodyViewTab.Visibility = Visibility.Hidden;
                htmlViewTab.Visibility = Visibility.Hidden;
                tabControl.SelectedIndex = 0;
            }
        }
Exemple #6
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());
        }