Пример #1
0
        public MailContent(MailContent mc)
        {
            if (mc == null)
            {
                return;
            }

            Type t = this.GetType();

            foreach (System.Reflection.PropertyInfo p in t.GetProperties())
            {
                if (p.CanWrite)
                {
                    p.SetValue(this, p.GetValue(mc, null), null);
                }
            }
        }
Пример #2
0
        public Comunicazioni(TipoCanale canaleType, String sottoTitolo, ActiveUp.Net.Mail.Message msg, String utente, int folderId, string folderTipo)
        {
            #region "sottotitolo"

            if (!String.IsNullOrEmpty(sottoTitolo))
            {
                this.RefIdSottotitolo = Convert.ToInt64(sottoTitolo);
            }

            #endregion

            #region "mail"

            MailContent mail = new MailContent();
            this.MailComunicazione = mail;

            #region "sender"

            mail.MailSender = msg.From.Email;

            #endregion

            #region "refs"
            mail.MailRefs = new List <MailRefs>();
            List <MailRefs> lR = new List <MailRefs>();
            var             to = from to0 in msg.To
                                 select new MailRefs
            {
                MailDestinatario = to0.Email,
                TipoRef          = AddresseeType.TO
            };
            if (to.Count() > 0)
            {
                lR.AddRange(to);
            }
            var cc = from cc0 in msg.Cc
                     select new MailRefs
            {
                MailDestinatario = cc0.Email,
                TipoRef          = AddresseeType.CC
            };
            if (cc.Count() > 0)
            {
                lR.AddRange(cc);
            }
            var ccn = from ccn0 in msg.Bcc
                      select new MailRefs
            {
                MailDestinatario = ccn0.Email,
                TipoRef          = AddresseeType.CCN
            };
            if (ccn.Count() > 0)
            {
                lR.AddRange(ccn);
            }
            if (lR.Count > 0)
            {
                mail.MailRefs = lR;
            }

            #endregion

            #region "subject"

            mail.MailSubject = msg.Subject;

            #endregion

            #region "body"

            mail.MailText = !String.IsNullOrEmpty(msg.BodyHtml.Text) ? msg.BodyHtml.Text : msg.BodyText.Text;

            #endregion

            #region "reply"
            if (!String.IsNullOrEmpty(msg.InReplyTo) && !String.IsNullOrEmpty(msg.InReplyTo.Trim()))
            {
                string follows = msg.InReplyTo.Trim();
                if (follows.StartsWith("<"))
                {
                    follows = follows.Substring(1);
                }
                if (follows.EndsWith(">"))
                {
                    follows = follows.Substring(0, follows.Length - 1);
                }
                long?flw    = null;
                long flwout = 0;
                if (long.TryParse(follows.Split('.')[0], out flwout))
                {
                    flw = flwout;
                }
                mail.Follows = flw;
            }
            #endregion
            #endregion

            #region "attachments"

            List <ComAllegato> all = null;
            if (msg.Attachments.Count > 0)
            {
                all = new List <ComAllegato>();

                for (int j = 0; j < msg.Attachments.Count; j++)
                {
                    ActiveUp.Net.Mail.MimePart mp = msg.Attachments[j];
                    ComAllegato a = new ComAllegato();
                    a.IdAllegato   = null;
                    a.AllegatoExt  = System.IO.Path.GetExtension(mp.Filename);
                    a.AllegatoExt  = a.AllegatoExt.Replace(".", string.Empty);
                    a.AllegatoFile = mp.BinaryContent;
                    a.AllegatoName = System.IO.Path.GetFileNameWithoutExtension(mp.Filename);
                    a.T_Progr      = j;
                    a.FlgInsProt   = AllegatoProtocolloStatus.UNKNOWN;
                    a.FlgProtToUpl = AllegatoProtocolloStatus.UNKNOWN;
                    a.RefIdCom     = null;

                    all.Add(a);
                }
            }
            this.ComAllegati = all;

            #endregion

            #region "notifica"

            this.MailNotifica = msg.ReplyTo.Email;

            #endregion

            #region "utente inserimento"

            this.UtenteInserimento = utente;

            #endregion

            #region "flusso comunicazione"

            this.SetStatoComunicazione(canaleType, MailStatus.INSERTED, utente);

            #endregion

            #region Folder
            this.FolderId   = folderId;
            this.FolderTipo = folderTipo;

            #endregion
        }