Ejemplo n.º 1
0
        public void Send()
        {
            try
            {
                Miami.Substitute.Dal.Template template = new Miami.Substitute.Dal.Template();
                DataRowView drv = template.LoadTemplateByName(type.ToString());
                if (drv != null && drv["Text"].ToString().Length > 0)
                {
                    MailAddressCollection ññTemp = cc;
                    bool testMode = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["UseTestEmailAddress"]);
                    if (testMode)
                    {
                        cc = new MailAddressCollection();
                        to = new MailAddressCollection();
                        to.Add(System.Configuration.ConfigurationManager.AppSettings["TestEmailAddress"]);
                    }
                    MailMessage myMail = new MailMessage();
                    myMail.From = from;
                    foreach (MailAddress item in to)
                    {
                        myMail.To.Add(item);
                    }
                    foreach (MailAddress item in cc)
                    {
                        myMail.CC.Add(item);
                    }
                    myMail.Subject    = Fill(drv["Header"].ToString());
                    myMail.Body       = Fill(drv["Text"].ToString());
                    myMail.Priority   = MailPriority.Normal;
                    myMail.IsBodyHtml = true;

                    Dal.MailLog mailLog = new Miami.Substitute.Dal.MailLog();
                    mailLog.AddNew();
                    mailLog.LocationId = LocationId;
                    mailLog.MailFrom   = myMail.From.Address;
                    mailLog.MailTo     = myMail.To.ToString();
                    if (ññTemp.Count > 0)
                    {
                        mailLog.MailTo += " , cc: " + ññTemp.ToString();
                    }
                    mailLog.MailType = type.ToString();
                    mailLog.Subject  = myMail.Subject;
                    mailLog.SendDate = DateTime.Now;
                    mailLog.Message  = myMail.Body;
                    mailLog.Save();
                    int countLogs = mailLog.GetAllMailLogByLocationId(LocationId).Count;
                    if (countLogs > 1000)
                    {
                        mailLog.DeleteMailLog(LocationId, countLogs - 1000);
                    }

                    SmtpClient smtpClient = new SmtpClient(System.Configuration.ConfigurationManager.AppSettings["SmtpServer"]);
                    smtpClient.Send(myMail);
                }
            }
            catch { }
        }
Ejemplo n.º 2
0
        private void UpdateToolTip(string value, UpdatePanel panel)
        {
            int mailLogId; int.TryParse(value, out mailLogId);

            Dal.MailLog mailLog = new Miami.Substitute.Dal.MailLog();
            mailLog.LoadByPrimaryKey(mailLogId);
            Label message = new Label();

            message.Text = mailLog.Message;
            panel.ContentTemplateContainer.Controls.Add(message);
        }
Ejemplo n.º 3
0
        public void Send()
        {
            try
            {
                Miami.Substitute.Dal.Template template = new Miami.Substitute.Dal.Template();
                DataRowView drv = template.LoadTemplateByName(type.ToString());
                if (drv != null && drv["Text"].ToString().Length > 0)
                {
                    MailAddressCollection ññTemp = cc;
                    bool testMode = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["UseTestEmailAddress"]);
                    if (testMode)
                    {
                        cc = new MailAddressCollection();
                        to = new MailAddressCollection();
                        to.Add(System.Configuration.ConfigurationManager.AppSettings["TestEmailAddress"]);
                    }
                    MailMessage myMail = new MailMessage();
                    myMail.From = from;
                    foreach (MailAddress item in to)
                        myMail.To.Add(item);
                    foreach (MailAddress item in cc)
                        myMail.CC.Add(item);
                    myMail.Subject = Fill(drv["Header"].ToString());
                    myMail.Body = Fill(drv["Text"].ToString());
                    myMail.Priority = MailPriority.Normal;
                    myMail.IsBodyHtml = true;

                    Dal.MailLog mailLog = new Miami.Substitute.Dal.MailLog();
                    mailLog.AddNew();
                    mailLog.LocationId = LocationId;
                    mailLog.MailFrom = myMail.From.Address;
                    mailLog.MailTo = myMail.To.ToString();
                    if (ññTemp.Count > 0)
                        mailLog.MailTo += " , cc: " + ññTemp.ToString();
                    mailLog.MailType = type.ToString();
                    mailLog.Subject = myMail.Subject;
                    mailLog.SendDate = DateTime.Now;
                    mailLog.Message = myMail.Body;
                    mailLog.Save();
                    int countLogs = mailLog.GetAllMailLogByLocationId(LocationId).Count;
                    if (countLogs > 1000)
                        mailLog.DeleteMailLog(LocationId, countLogs - 1000);

                    SmtpClient smtpClient = new SmtpClient(System.Configuration.ConfigurationManager.AppSettings["SmtpServer"]);
                    smtpClient.Send(myMail);
                }
            }
            catch { }
        }
Ejemplo n.º 4
0
 private void UpdateToolTip(string value, UpdatePanel panel)
 {
     int mailLogId; int.TryParse(value, out mailLogId);
     Dal.MailLog mailLog = new Miami.Substitute.Dal.MailLog();
     mailLog.LoadByPrimaryKey(mailLogId);
     Label message = new Label();
     message.Text = mailLog.Message;
     panel.ContentTemplateContainer.Controls.Add(message);
 }