public void SendMail(Object Sender, ImageClickEventArgs E) { string urlImagen = "http://ecas.co/images/" + GlobalData.getEMPRESA() + ".png"; string nombre = "Informe Pedidos Sugeridos"; string empresa = DBFunctions.SingleDataGlobal("select gemp_descripcion from gempresa where gemp_nombre='" + GlobalData.getEMPRESA() + "';"); //if(this.dgSugerido.Items.Count>0) //{ // StringBuilder SB= new StringBuilder(); // StringWriter SW= new StringWriter(SB); // HtmlTextWriter htmlTW = new HtmlTextWriter(SW); // plReport.RenderControl(htmlTW); // MailMessage MyMail = new MailMessage(); // MyMail.From = ConfigurationManager.AppSettings["EmailFrom"]; // MyMail.To = tbEmail.Text; // MyMail.Subject = "SUGERIDO"; // MyMail.Body = SB.ToString(); // MyMail.BodyFormat = MailFormat.Html; // try{ // SmtpMail.Send(MyMail);} // catch(Exception e){ // lb.Text = e.ToString(); // } //} //else dtSugerido = (DataTable)ViewState["dgSugerido"]; dtSugerido.TableName = "Pedido Sigerido"; //Create a New Workbook. XLWorkbook wb = new XLWorkbook(); //Add the DataTable as Excel Worksheet. wb.Worksheets.Add(dtSugerido); MemoryStream memoryStream = new MemoryStream(); //Save the Excel Workbook to MemoryStream. wb.SaveAs(memoryStream); string mensajeExcel = @"<div style='position: absolute; background-color:#EEEFD9;width: 35%;border-radius: 10px;margin: auto;padding: 20px;box-shadow: 1px 7px 9px #888888;'> <img style='width: 20%; position: absolute; right: 2%;' src='" + urlImagen + @"' /><br><br> <b><font size='5'>Excel Generado:</font></b> <br>" + nombre + @"<br><br> <b>Reciba un cordial saludo</b>, <br> Ha recibido un Excel usando el Sistema Ecas <br> Dicho Excel se encuentra disponible como archivo <br> adjunto en este correo. <br><br> <b>Gracias por su atención.</b> <br> <i>eCAS-AMS.</i> </div> <br><br>"; //Convert MemoryStream to Byte array. byte[] bytes = memoryStream.ToArray(); memoryStream.Close(); try { AMS_Tools_Email.enviarMail(tbEmail.Text, "Ha recibido un Reporte Excel de " + empresa, mensajeExcel, TipoCorreo.HTML, bytes); Utils.MostrarAlerta(Response, "Email enviado satisfactoriamente a: " + tbEmail.Text); //Response.Redirect(indexPage + "?process=DBManager.Selects&table=" + ds.DataSetName); } catch (Exception z) { lb.Text = z.Message; } }
public void SendMail(Object Sender, ImageClickEventArgs e) { string result = ""; if (tbEmail.Text == "") { Utils.MostrarAlerta(Response, "Debe ingresar un correo. Revise por favor"); return; } try { Tools.AMS_Tools_Email envio = new AMS_Tools_Email(); //string mensajeExcel = // @"<div style='position: absolute; background-color:#EEEFD9;width: 35%;border-radius: 10px;margin: auto;padding: 20px;box-shadow: 1px 7px 9px #888888;'> // <img style='width: 20%; position: absolute; right: 2%;' src='" + urlImagen + @"' /><br><br> // <b><font size='5'>Excel Generado:</font></b> // <br>" + nombre.Split('_')[0] + // @"<br><br> // <b>Reciba un cordial saludo</b>, <br> // Ha recibido un Excel usando el Sistema Ecas <br> // Dicho Excel se encuentra disponible como archivo <br> // adjunto en este correo. // <br><br> // <b>Gracias por su atención.</b> // <br> // <i>eCAS-AMS.</i> // </div> // <br><br>"; //string empresa = DBFunctions.SingleDataGlobal("select gemp_descripcion from gempresa where gemp_nombre='" + GlobalData.getEMPRESA() + "';"); DataSet ds = new DataSet(); ds.Tables.Add((DataTable)Session["dtDetalles"]); ds.DataSetName = "TablaContabilidad"; envio.Correo = tbEmail.Text; envio.DsExcel = ds;//new DataSet().Tables.Add((DataTable)Session["dtDetalles"]); envio.ImageButton1_Click(Sender, e); //result = Tools.AMS_Tools_Email.enviarMail(tbEmail.Text, "Ha recibido un Reporte Excel de " + empresa, mensajeExcel, TipoCorreo.HTML, bytes); if (result == "") { Utils.MostrarAlerta(Response, "Email con Reporte ha sido enviado correctamente a: " + tbEmail.Text); } } catch (Exception z) { } /*MailMessage MyMail = new MailMessage(); * MyMail.From = ConfigurationManager.AppSettings["EmailFrom"]; * MyMail.To = tbEmail.Text; * MyMail.Subject = "Proceso : Hechos Económicos"; * MyMail.Body = (RenderHtml()); * MyMail.BodyFormat = MailFormat.Html; * try * { * SmtpMail.Send(MyMail); * } * catch(Exception e) * { * lbInfo.Text = e.ToString(); * }*/ }