public Int16 CartaoParaImpressaoFamiliar() { Int16 CartaoLote = 100; try { PessoaDAO DAO = new PessoaDAO(); LogNegocios Log_N = new LogNegocios(); //Definir novo lote CartaoLote = DAO.RecuperarCartaoLote(); CartaoLote++; //Recupera Cartões gerados; List <PessoaController> Cartoes = DAO.CartoesParaImpressao(CartaoLote, 1); /*Enviar Email*/ if (Cartoes.Count > 0) { string str_from_address = ParametrosNegocios.EmailSaidaLogin;//sender string str_name = ParametrosNegocios.NomeConta; //The To address (Email ID) string str_to_address = "*****@*****.**";//recipient //string str_to_address = "*****@*****.**";//recipient System.Net.Mail.MailMessage email_msg = new MailMessage(); //Specifying From,Sender & Reply to address email_msg.From = new MailAddress(str_from_address, str_name); email_msg.Sender = new MailAddress(str_from_address, str_name); //email_msg.ReplyTo = new MailAddress(str_from_address, str_name); //The To Email id email_msg.To.Add(str_to_address); email_msg.Subject = "Cartões para impressão (Plano Familiar)";//Subject of email StringBuilder HTML = new StringBuilder(); HTML.Append("<!DOCTYPE html>"); HTML.Append("<html xmlns='http://www.w3.org/1999/xhtml'>"); HTML.Append("<head runat='server'>"); HTML.Append("<meta http-equiv='Content -Type' content='text/html; charset=utf-8'/>"); HTML.Append("<title>Cartões para Impressão Plano Familiar</title>"); HTML.Append("<style>"); HTML.Append("body"); HTML.Append("{"); HTML.Append("margin: 0px"); HTML.Append("}"); HTML.Append(".container"); HTML.Append("{"); HTML.Append("width: 100 %;"); HTML.Append("height: 100 %;"); HTML.Append("background: #EDEDED;"); HTML.Append("display:flex;"); HTML.Append("flex-direction:row;"); HTML.Append("justify-content:center;"); HTML.Append("align-items:center"); HTML.Append("}"); HTML.Append(".box {"); HTML.Append("width:760px;"); HTML.Append("height:300px;"); HTML.Append("background:#FFFFFF;"); HTML.Append("}"); HTML.Append(".auto-style1 {"); HTML.Append("text-align:left;"); HTML.Append("}"); HTML.Append("</style>"); HTML.Append("</head>"); HTML.Append("<body>"); HTML.Append("<div class='container'>"); HTML.Append("<div class='box'>"); HTML.Append("<div style='background-color:#0071C5; font-size: 26px; font-weight: bold; color: #FFFFFF;'>"); HTML.Append("Clube Conteza"); HTML.Append("</div>"); HTML.Append("<br/>"); HTML.Append("<div style='background-color:#F3F3F3; text-align: center;' >"); HTML.Append("Cartões para Impressão</div>"); HTML.Append("<br/>"); HTML.Append("<div> "); HTML.Append("Segue lista para impressão de cartões do Plano Familiar</div>"); HTML.Append("<br/>"); HTML.Append("<div>"); HTML.Append("<table style='padding: 2px; margin: inherit; border: medium solid #000000; width:100%; table-layout: auto; border-spacing: inherit; border-collapse: collapse;'>"); HTML.Append("<tr>"); HTML.Append("<td style='border-style: solid; background-color: #4472C4;'>Contrato</td>"); HTML.Append("<td style='border-style: solid; background-color: #4472C4;'>ID Pessoa</td>"); HTML.Append("<td style='border-style: solid; background-color: #4472C4;'>Cartão</td>"); HTML.Append("<td style='border-style: solid; background-color: #4472C4;'>Lote</td>"); HTML.Append("<td style='border-style: solid; background-color: #4472C4;'>Nome Completo</td>"); HTML.Append("<td style='border-style: solid; background-color: #4472C4;'>Celular</td>"); HTML.Append("<td style='border-style: solid; background-color: #4472C4;'>Ponto de Venda</td>"); HTML.Append("</tr>"); int Linha = 0; foreach (PessoaController Cartao in Cartoes) { HTML.Append("<tr>"); if (Linha == 0) { HTML.Append("<td style='border-style: solid; background-color:#D9E2F3'>"); } else { HTML.Append("<td style='border-style: solid; background-color:#FFFFFF'>"); } HTML.Append(Cartao.TB012_Id); HTML.Append("</td>"); if (Linha == 0) { HTML.Append("<td style='border-style: solid; background-color:#D9E2F3'>"); } else { HTML.Append("<td style='border-style: solid; background-color:#FFFFFF'>"); } HTML.Append(Cartao.TB013_id); HTML.Append("</td>"); if (Linha == 0) { HTML.Append("<td style='border-style: solid; background-color:#D9E2F3'>"); } else { HTML.Append("<td style='border-style: solid; background-color:#FFFFFF'>"); } HTML.Append(Cartao.TB013_Cartao); HTML.Append("</td>"); if (Linha == 0) { HTML.Append("<td style='border-style: solid; background-color:#D9E2F3'>"); } else { HTML.Append("<td style='border-style: solid; background-color:#FFFFFF'>"); } /**/ HTML.Append(Cartao.TB013_CartaoLote); HTML.Append("</td>"); if (Linha == 0) { HTML.Append("<td style='border-style: solid; background-color:#D9E2F3'>"); } else { HTML.Append("<td style='border-style: solid; background-color:#FFFFFF'>"); } /**/ HTML.Append(Cartao.TB013_NomeCompleto); //HTML.Append("</td>"); //HTML.Append("</tr>"); /**/ if (Linha == 0) { HTML.Append("<td style='border-style: solid; background-color:#D9E2F3'>"); } else { HTML.Append("<td style='border-style: solid; background-color:#FFFFFF'>"); } HTML.Append(Cartao.Contato.TB009_Contato); HTML.Append("</td>"); /*Ponto de Venda*/ if (Linha == 0) { HTML.Append("<td style='border-style: solid; background-color:#D9E2F3'>"); } else { HTML.Append("<td style='border-style: solid; background-color:#FFFFFF'>"); } HTML.Append(Cartao.PontoDeVenda.TB002_Ponto.TrimEnd()); HTML.Append("</td>"); /*Fim ponto de venda*/ HTML.Append("</tr>"); /*Rotina para o Log*/ LogController Log_C = new LogController(); Log_C.TB012_Id = Cartao.TB012_Id; Log_C.TB011_Id = 0; Log_C.TB000_IdTabela = 13; Log_C.TB000_Tabela = "Cartao"; Log_C.TB000_Data = DateTime.Now; Log_C.TB000_Descricao = string.Format(MensagensLog.L0021.ToString(), Cartao.TB013_Cartao); Log_N.LogInsert(Log_C); /**/ } HTML.Append("</table>"); HTML.Append("</div>"); HTML.Append("<div>"); HTML.Append("</div>"); HTML.Append("</div>"); HTML.Append("</div>"); HTML.Append("</body>"); HTML.Append("</html>"); email_msg.IsBodyHtml = true; email_msg.Body = HTML.ToString(); //body //Create an object for SmtpClient class SmtpClient mail_client = new SmtpClient(); //Providing Credentials (Username & password) NetworkCredential network_cdr = new NetworkCredential(); network_cdr.UserName = str_from_address; network_cdr.Password = ParametrosNegocios.EmailSaidaSenha; mail_client.Credentials = network_cdr; //Specify the SMTP Port mail_client.Port = ParametrosNegocios.EmailSaidaPorta; //Specify the name/IP address of Host mail_client.Host = ParametrosNegocios.EmailSaidaSMTP; //Uses Secure Sockets Layer(SSL) to encrypt the connection mail_client.EnableSsl = true; //Now Send the message mail_client.Send(email_msg); /*Apos Enviar Email Atualizar Status do Cartão*/ DAO.CartoesUpdateStatus(CartaoLote, 2); } /*Fim Email*/ if (Cartoes.Count == 0) { CartaoLote = 0; } } catch (Exception ex) { throw ex; } return(CartaoLote); }