private bool sendEmail(ClsEmail email) { try { MailMessage mail = new MailMessage(); SmtpClient SmtpServer = new SmtpClient("zimbra.perto.com.br"); SmtpServer.Port = 587; SmtpServer.Credentials = new System.Net.NetworkCredential("suporte.sw", "S.p2015!"); SmtpServer.EnableSsl = false; mail.From = new MailAddress("*****@*****.**"); foreach (string para in email.To) { mail.To.Add(para); } mail.Subject = email.Subjetc; mail.IsBodyHtml = true; mail.Body = email.Body; SmtpServer.Send(mail); this.setEmailEnviadoMonitoracao(email.Monitoracao.IdMonitoracao); return(true); } catch (Exception ex) { return(false); } }
private List <ClsEmail> getEmailMonitoracaoAlerta() { ClsEmail e; List <ClsEmail> emails; ClsMonitoracaoBus mb = new ClsMonitoracaoBus(); List <ClsMonitoracao> lstMonitoracao = new List <ClsMonitoracao>(); lstMonitoracao = mb.getMonitoracoesEmailAlerta(); try { if (lstMonitoracao != null) { if (lstMonitoracao.Count > 0) { emails = new List <ClsEmail>(); foreach (ClsMonitoracao m in lstMonitoracao) { e = new ClsEmail(); e.Monitoracao = m; e.Subjetc = m.DescCliente + " | " + m.DescAlerta + " | " + m.DescLocal; e.Body = m.DescCliente + " | " + m.DescAlerta + " | " + m.DescLocal + Environment.NewLine; e.Body += "Data: " + m.DataHoraAlerta.ToString() + Environment.NewLine; e.Body += "Local: " + m.DescLocal + Environment.NewLine; e.Body += "Equipamento: " + m.DescEquipamento + Environment.NewLine; e.Body += "Descrição: " + m.DescricaoAlerta + Environment.NewLine; e.To = this.getEnderecosEmails(m.IdMonitoracao); emails.Add(e); } return(emails); } else { return(null); } } else { return(null); } } catch (Exception ex) { return(null); } }