예제 #1
0
        internal static SerializeableAttachment GetSerializeableAttachment(Attachment att)
        {
            if (att == null)
            {
                return(null);
            }

            var saa = new SerializeableAttachment();

            saa._contentId          = att.ContentId;
            saa._contentDisposition =
                SerializeableContentDisposition.GetSerializeableContentDisposition(att.ContentDisposition);

            if (att.ContentStream != null)
            {
                var bytes = new byte[att.ContentStream.Length];
                att.ContentStream.Read(bytes, 0, bytes.Length);

                saa._contentStream = new MemoryStream(bytes);
            }

            saa._contentType      = SerializeableContentType.GetSerializeableContentType(att.ContentType);
            saa._name             = att.Name;
            saa._transferEncoding = att.TransferEncoding;
            saa._nameEncoding     = att.NameEncoding;
            return(saa);
        }
예제 #2
0
        ///
        /// Creates a new serializeable mailmessage based on a MailMessage object
        ///
        public SerializeableMailMessage(MailMessage mailMessage)
        {
            IsBodyHtml = mailMessage.IsBodyHtml;
            Body       = mailMessage.Body;
            Subject    = mailMessage.Subject;
            From       = SerializeableMailAddress.GetSerializeableMailAddress(mailMessage.From);
            _to        = new List <SerializeableMailAddress>();
            foreach (var mailAddress in mailMessage.To)
            {
                _to.Add(SerializeableMailAddress.GetSerializeableMailAddress(mailAddress));
            }

            _cc = new List <SerializeableMailAddress>();
            foreach (var mailAddress in mailMessage.CC)
            {
                _cc.Add(SerializeableMailAddress.GetSerializeableMailAddress(mailAddress));
            }

            _bcc = new List <SerializeableMailAddress>();
            foreach (var mailAddress in mailMessage.Bcc)
            {
                _bcc.Add(SerializeableMailAddress.GetSerializeableMailAddress(mailAddress));
            }

            _attachments = new List <SerializeableAttachment>();
            foreach (var attachment in mailMessage.Attachments)
            {
                _attachments.Add(SerializeableAttachment.GetSerializeableAttachment(attachment));
            }

            _bodyEncoding = mailMessage.BodyEncoding;

            _deliveryNotificationOptions = mailMessage.DeliveryNotificationOptions;
            _headers         = SerializeableCollection.GetSerializeableCollection(mailMessage.Headers);
            _priority        = mailMessage.Priority;
            ReplyTo          = mailMessage.ReplyToList.Select(SerializeableMailAddress.GetSerializeableMailAddress).ToList();
            Sender           = SerializeableMailAddress.GetSerializeableMailAddress(mailMessage.Sender);
            _subjectEncoding = mailMessage.SubjectEncoding;

            foreach (AlternateView av in mailMessage.AlternateViews)
            {
                _alternateViews.Add(SerializeableAlternateView.GetSerializeableAlternateView(av));
            }
        }