Example #1
0
        /// <summary>
        /// Sets the message body.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="child">The child.</param>
        private void SetMessageBody(SidePOPMailMessage message, MimeEntity child)
        {
            Encoding encoding = child.GetEncoding();

            message.Body         = ContentDecoder.DecodeString(child);;
            message.BodyEncoding = encoding;
            message.IsBodyHtml   = string.Equals(MediaTypes.TextHtml, child.ContentType.MediaType, StringComparison.InvariantCultureIgnoreCase);
        }
Example #2
0
        /// <summary>
        /// Creates the alternate view.
        /// </summary>
        /// <param name="view">The view.</param>
        /// <returns></returns>
        private AlternateView CreateAlternateView(MimeEntity view)
        {
            MemoryStream  stream        = new MemoryStream(ContentDecoder.DecodeBytes(view), false);
            AlternateView alternateView = new AlternateView(stream, view.ContentType);

            alternateView.TransferEncoding = view.ContentTransferEncoding;
            alternateView.ContentId        = TrimBrackets(view.ContentId);
            return(alternateView);
        }
Example #3
0
        /// <summary>
        /// Creates the attachment.
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <returns></returns>
        private Attachment CreateAttachment(MimeEntity entity)
        {
            MemoryStream memoryStream = new MemoryStream(ContentDecoder.DecodeBytes(entity), false);
            Attachment   attachment   = new Attachment(memoryStream, entity.ContentType);

            if (entity.ContentDisposition != null)
            {
                attachment.ContentDisposition.Parameters.Clear();
                foreach (string key in entity.ContentDisposition.Parameters.Keys)
                {
                    //Skip values that will be strongly typed copied after this loop: it happens that date string
                    //will not be parsed correctly when going through Parameters.Add but are already parsed into entity.ContentDisposition
                    if (key == "creation-date" ||
                        key == "modification-date" ||
                        key == "read-date" ||
                        key == "size" ||
                        key == "filename")
                    {
                        continue;
                    }

                    attachment.ContentDisposition.Parameters.Add(key, entity.ContentDisposition.Parameters[key]);
                }

                attachment.ContentDisposition.CreationDate     = entity.ContentDisposition.CreationDate;
                attachment.ContentDisposition.DispositionType  = entity.ContentDisposition.DispositionType;
                attachment.ContentDisposition.FileName         = entity.ContentDisposition.FileName;
                attachment.ContentDisposition.Inline           = entity.ContentDisposition.Inline;
                attachment.ContentDisposition.ModificationDate = entity.ContentDisposition.ModificationDate;
                attachment.ContentDisposition.ReadDate         = entity.ContentDisposition.ReadDate;
                attachment.ContentDisposition.Size             = entity.ContentDisposition.Size;
            }

            if (!string.IsNullOrEmpty(entity.ContentId))
            {
                attachment.ContentId = TrimBrackets(entity.ContentId);
            }

            attachment.TransferEncoding = entity.ContentTransferEncoding;

            return(attachment);
        }