Exemple #1
0
        public void sendEmail(SMTPEmail email)
        {
            try
            {
                Admin aux = new Admin();
                MailMessage Email;

                Email = new MailMessage(email.From, email.To, email.subject, email.Message);

                SmtpClient smtpMail = new SmtpClient(email.SMTPClient);
                Email.IsBodyHtml = true;

                smtpMail.UseDefaultCredentials = false;
                smtpMail.Host = email.SMTPClient;
                smtpMail.Port = email.SMTPPort;
                smtpMail.EnableSsl = false;
                smtpMail.Credentials = new NetworkCredential(aux.GetGeneralParameterValue("EmailSMTP Sitio"), aux.GetGeneralParameterValue("PasswordSMTP Sitio"));//[email protected] // Aep123456

                smtpMail.Send(Email);
            }
            catch (Exception ex)
            {
                this.lblMessage.InnerText = ex.Message;
            }
        }
Exemple #2
0
        protected void btnEnviar_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.ValidateData())
                {
                    Admin aux = new Admin();
                    var email = new SMTPEmail();

                    email.From = aux.GetGeneralParameterValue("EmailSMTP Sitio");
                    email.To = aux.GetGeneralParameterValue("EmailSMTP Sitio");
                    email.subject = "Contacto - Web Site";
                    email.SMTPClient = aux.GetGeneralParameterValue("SMTP Client");
                    email.SMTPPort = Convert.ToInt32(aux.GetGeneralParameterValue("SMTP Port"));

                    email.Message = String.Concat(GetHtmlTemplate(txtNombre.Text,txtEmail.Text,txtTelefono.Text,txtDetalle.Value));

                    this.sendEmail(email);

                    this.divContenido.Visible = false;
                    this.divContentMessage.Visible = true;
                }
            }
            catch (Exception ex)
            {
                this.divContenido.Visible = false;
                this.lblError.InnerText = ex.Message;
            }
        }
Exemple #3
0
        private void sendEmail(TechLogInformation tech)
        {
            try
            {
                var aux = new Admin();
                SMTPEmail email = new SMTPEmail();

                email.From = aux.GetGeneralParameterValue("EmailSMTP Error");
                email.To = aux.GetGeneralParameterValue("ToEmail Error");
                email.subject = aux.GetGeneralParameterValue("Subject Error");
                email.SMTPClient = aux.GetGeneralParameterValue("SMTP Client");
                email.SMTPPort = Convert.ToInt32(aux.GetGeneralParameterValue("SMTP Port"));

                email.Message = "<label style=\"display:block;\">Página: " + tech.ClassName + "</label></br></br><label style=\"display:block;\">Método: " + tech.MethodName + "</label></br></br><label style=\"display:block;\">Excepción: " + tech.ExceptionDetail + "</label></br></br>";

                MailMessage Email = new MailMessage(email.From, email.To, email.subject, email.Message);

                var smtpMail = new SmtpClient(email.SMTPClient);
                Email.IsBodyHtml = true;

                smtpMail.UseDefaultCredentials = false;
                smtpMail.Host = email.SMTPClient;
                smtpMail.Port = email.SMTPPort;
                smtpMail.EnableSsl = false;
                smtpMail.Credentials = new NetworkCredential(aux.GetGeneralParameterValue("EmailSMTP Error"), aux.GetGeneralParameterValue("PasswordSMTP Error"));//[email protected] // Aep123456

                smtpMail.Send(Email);
            }
            catch (Exception ex)
            {
                //log the error
                SaveTechLog(System.Reflection.MethodBase.GetCurrentMethod().Name, LevelError.ERROR, ex);
                throw ex;
            }
        }