Пример #1
0
    public static void Enviar_Correo(string strID, string strMensaje)
    {
        string strQuery = "SELECT emailfrom, emailto, emailsubject, mensaje " +
                          " FROM mensajes_correo" +
                          " WHERE ID = " + strID;

        DataSet objDataResult = CComunDB.CCommun.Ejecutar_SP(strQuery);

        CCorreo objCorreo = new CCorreo();

        objCorreo.strAsunto = objDataResult.Tables[0].Rows[0]["emailsubject"].ToString();
        objCorreo.strDe     = objDataResult.Tables[0].Rows[0]["emailfrom"].ToString();

        string[] strEmailsPara = objDataResult.Tables[0].Rows[0]["emailto"].ToString().Split(';');

        foreach (string strEmail in strEmailsPara)
        {
            if (!string.IsNullOrEmpty(strEmail))
            {
                objCorreo.strPara.Add(strEmail);
            }
        }

        objCorreo.strMensaje = objDataResult.Tables[0].Rows[0]["mensaje"].ToString() + strMensaje;

        string strError = string.Empty;

        objCorreo.Enviar(out strError);
    }
        protected void btnRechazarReserva_Click(object sender, EventArgs e)
        {
            String  email_paciente = txtEmailPacienteRechazoReserva.Text;
            Reserva objReserva     = obtenerDatosReservaRechazar();
            bool    respuesta      = new ReservaLN().RechazarReserva(objReserva);

            if (respuesta == true)
            {
                CCorreo objCorreo = new CCorreo(email_paciente, "RECHAZO - SOLICITUD DE RESERVA", "Su reserva se ha rechazado. \r\nMotivo: " + txtMotivoRechazoReserva.Text + ". \r\nGracias por confiar en nosotros!!!");
                if (objCorreo.Estado)
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "SweetAlert", "MensajeReservaRechazadaCorrecta();", true);
                }
                else
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "SweetAlert", "MensajeReservaRechazadaCorrectaSinCorreo();", true);
                }
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "SweetAlert", "MensajeReservaRechazadaIncorrecta();", true);
            }
        }
        protected void btnConfirmarReserva_Click(object sender, EventArgs e)
        {
            String  email_paciente = txtEmailPacienteConfirmarReserva.Text;
            Reserva objReserva     = obtenerDatosReserva();
            bool    respuesta      = new ReservaLN().ConfirmarReserva(objReserva);

            if (respuesta == true)
            {
                CCorreo objCorreo = new CCorreo(email_paciente, "CONFIRMACIÓN - SOLICITUD DE RESERVA", "Su reserva se ha confirmado l@ esperamos el " + txtFechaAtencionConfirmarReserva.Text + " a las " + txtHoraAtencionConfirmarReserva.Text + ". \r\nObservacion: " + txtDescripcionConfirmarReserva.Text + ". \r\nGracias por confiar en nosotros!!!");
                if (objCorreo.Estado)
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "SweetAlert", "MensajeReservaConfirmada();", true);
                }
                else
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "SweetAlert", "MensajeReservaConfirmadaCorrectaCorreoFallido();", true);
                }
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "SweetAlert", "MensajeReservaConfirmadaIncorrecta();", true);
            }
        }
Пример #4
0
    private bool Enviar_Correo()
    {
        CCorreo objCorreo = new CCorreo();

        objCorreo.strAsunto = this.txtAsunto.Text.Trim();
        objCorreo.strDe     = this.hdDe.Value;

        objCorreo.strMensaje = this.txtMensaje.Text.Trim();

        char[] chSeparador = new char[] { ' ' };
        if (this.txtPara.Text.Trim().Contains(","))
        {
            chSeparador[0] = ',';
        }
        else
        if (this.txtPara.Text.Trim().Contains(";"))
        {
            chSeparador[0] = ';';
        }

        string[] strEmailsPara = this.txtPara.Text.Trim().Split(chSeparador);

        foreach (string strEmail in strEmailsPara)
        {
            if (!string.IsNullOrEmpty(strEmail))
            {
                objCorreo.strPara.Add(strEmail);
            }
        }

        if (!string.IsNullOrEmpty(this.txtCC.Text.Trim()))
        {
            chSeparador[0] = ' ';
            if (this.txtCC.Text.Trim().Contains(","))
            {
                chSeparador[0] = ',';
            }
            else
            if (this.txtCC.Text.Trim().Contains(";"))
            {
                chSeparador[0] = ';';
            }

            string[] strEmailsCC = this.txtCC.Text.Trim().Split(chSeparador);

            foreach (string strEmail in strEmailsCC)
            {
                if (!string.IsNullOrEmpty(strEmail))
                {
                    objCorreo.strCC.Add(strEmail);
                }
            }
        }

        objCorreo.strAttachments.Add(Server.MapPath("../xml_facturas" + HttpContext.Current.Request.ApplicationPath + "/PDF_" +
                                                    this.hdFact.Value + ".pdf"));

        objCorreo.strAttachments.Add(Server.MapPath("../xml_facturas" + HttpContext.Current.Request.ApplicationPath + "/CFDI_" +
                                                    this.hdFact.Value + ".xml"));

        string strMensaje = string.Empty;

        if (objCorreo.Enviar(out strMensaje))
        {
            return(true);
        }
        else
        {
            ((master_MasterPagePopUp)Page.Master).MostrarMensajeError("No se pudo enviar el correo: " + strMensaje);
            return(false);
        }
    }