private bool EnviarEmail() { try { Utilitarios.Email.MailMessage msg = new Utilitarios.Email.MailMessage(); string strCorpo = string.Empty; FileStream fileStream; Encoding encoding = Encoding.GetEncoding("ISO-8859-1"); fileStream = new FileStream(System.Configuration.ConfigurationManager.AppSettings["BradescoRI.Template.FaleConosco"], FileMode.Open); StreamReader streamReader = new StreamReader(fileStream, encoding); strCorpo = streamReader.ReadToEnd(); streamReader.Close(); if (!string.IsNullOrEmpty(strCorpo)) { strCorpo = strCorpo.Replace("#NOME#", txtNome.Text); strCorpo = strCorpo.Replace("#EMAIL#", txtEmail.Text); strCorpo = strCorpo.Replace("#TELEFONEDDD#", txtTelefoneDDD.Text); strCorpo = strCorpo.Replace("#TELEFONE#", txtTelefone.Text); strCorpo = strCorpo.Replace("#EMPRESA#", txtEmpresa.Text); strCorpo = strCorpo.Replace("#MENSAGEM#", txtMensagem.Text); strCorpo = strCorpo.Replace("#ASSUNTO#", ddlAssunto.SelectedItem.Text); string[] lstEmail = Email.Split(';'); for (int i = 0; i < lstEmail.Length; i++) { // Adiciona Destinatário msg.To.Add(new System.Net.Mail.MailAddress(lstEmail[i])); } msg.Body = strCorpo; msg.IsBodyHtml = true; msg.Subject = Resources.FaleConosco.Email_Titulo_Fale_Conosco; //ENVIA O E-MAIL new Utilitarios.Email.SendMail(msg, false); return(true); } else { return(false); } } catch (Exception ex) { throw ex; } }
private void EnviarEmail(Usuario objUsuario) { try { Utilitarios.Email.MailMessage msg = new Utilitarios.Email.MailMessage(); string strCorpo = string.Empty; FileStream fileStream; Encoding encoding = Encoding.GetEncoding("ISO-8859-1"); fileStream = new FileStream(System.Configuration.ConfigurationManager.AppSettings["BradescoRI.Template.EsqueciMinhaSenha"], FileMode.Open); StreamReader streamReader = new StreamReader(fileStream, encoding); strCorpo = streamReader.ReadToEnd(); streamReader.Close(); if (!string.IsNullOrEmpty(strCorpo)) { string novaSenha = Utilitarios.CriptografiaSeguranca.GerarSenha(); strCorpo = strCorpo.Replace("#NOME#", objUsuario.Nome); strCorpo = strCorpo.Replace("#LOGIN#", objUsuario.Login); strCorpo = strCorpo.Replace("#SENHA#", novaSenha); DOUsuario.AtualizarSenha(objUsuario.Id, Utilitarios.EnCryptDecrypt.CryptorEngine.Encrypt(novaSenha)); // Adiciona Destinatário msg.To.Add(new System.Net.Mail.MailAddress(objUsuario.Email)); msg.Body = strCorpo; msg.IsBodyHtml = true; msg.Subject = Resources.Login.Email_Titulo_Esqueci_Senha; //ENVIA O E-MAIL new Utilitarios.Email.SendMail(msg, false); } else { lblMensagem.Text = Resources.Login.Mensagem_Erro_Template_Email; phlMensagem.Visible = true; } } catch (Exception ex) { throw ex; } }
private void EnviarEmail() { if (gobjModContato != null) { Utilitarios.Email.MailMessage objMailMessage = new Utilitarios.Email.MailMessage(); string strCorpo = gobjModContato.ConteudoTemplate; strCorpo = strCorpo.Replace("%%Nome%%", txtNome.Text); strCorpo = strCorpo.Replace("%%Email%%", txtEmail.Text); if (!String.IsNullOrWhiteSpace(txtTelefone.Text)) { string strTelefone = string.Empty; if (!String.IsNullOrWhiteSpace(txtTelefoneDdd.Text)) { strTelefone = String.Format("({0}) {1}", txtTelefoneDdd.Text, txtTelefone.Text); } else { strTelefone = txtTelefone.Text; } strCorpo = strCorpo.Replace("%%Telefone%%", strTelefone); } strCorpo = strCorpo.Replace("%%Empresa%%", txtEmpresa.Text); strCorpo = strCorpo.Replace("%%Assunto%%", ddlAssuntos.SelectedValue); strCorpo = strCorpo.Replace("%%Mensagem%%", txtMensagem.Text); string[] lstEmailTo = gobjModContato.EmailTo.Split(';'); string[] lstEmailTocc = null; string[] lstEmailTocco = null; if (!string.IsNullOrWhiteSpace(gobjModContato.EmailToCc)) { lstEmailTocc = gobjModContato.EmailToCc.Split(';'); } ; if (!string.IsNullOrWhiteSpace(gobjModContato.EmailToCco)) { lstEmailTocco = gobjModContato.EmailToCco.Split(';'); } ; //Destinatário(s) foreach (string strEmailTo in lstEmailTo) { if (!String.IsNullOrWhiteSpace(strEmailTo)) { objMailMessage.To.Add(new System.Net.Mail.MailAddress(strEmailTo)); } } //Destinatário(s) em cópia if (lstEmailTocc != null) { foreach (string strEmailTocc in lstEmailTocc) { if (!String.IsNullOrWhiteSpace(strEmailTocc)) { objMailMessage.CC.Add(new System.Net.Mail.MailAddress(strEmailTocc)); } } } //Destinatário(s) em cópia oculta if (lstEmailTocco != null) { foreach (string strEmailTocco in lstEmailTocco) { if (!String.IsNullOrWhiteSpace(strEmailTocco)) { objMailMessage.Bcc.Add(new System.Net.Mail.MailAddress(strEmailTocco)); } } } objMailMessage.Body = strCorpo; objMailMessage.IsBodyHtml = true; objMailMessage.Subject = gobjModContato.AssuntoEmail; //ENVIA O E-MAIL new Utilitarios.Email.SendMail(objMailMessage, false); lblMensagem.Visible = true; } }