Exemplo n.º 1
0
        internal static SerializeableMailAddress GetSerializeableMailAddress(MailAddress ma)
        {
            if (ma == null)
            {
                return(null);
            }

            var sma = new SerializeableMailAddress(ma.Address, ma.DisplayName, ma.Host, ma.User);

            return(sma);
        }
Exemplo n.º 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));
            }
        }