private bool NewCommentSendMail(Comment entComment) { List<GlobalAttribute> listGlobalAttributes = new CoreLibrary.Configuration.Controller().GetConfiguration(3); string PortalAddress = string.Empty; PortalAddress = String.Format("{0}://{1}:{2}{3}", HttpContext.Current.Request.Url.Scheme, HttpContext.Current.Request.Url.Host, HttpContext.Current.Request.Url.Port, Request.ApplicationPath != "/" ? Request.ApplicationPath : ""); StringBuilder sbBody = new StringBuilder(); sbBody.AppendLine("<p>"); //sbBody.AppendLine("<IMG src=\"Logo.jpg\"><br/>"); sbBody.AppendLine("<strong>Nuevo Comentario</strong>"); sbBody.AppendLine("<br/>"); sbBody.AppendLine(String.Format("Para ver la información da clic aqui:<a href=\"{0}/LoginPage.aspx\" >Ingresar</a>", PortalAddress)); sbBody.AppendLine("</p>"); //string slImagePath = Server.MapPath(@"~/App_Themes/Default/Images/Logo.jpg"); MailMessage mail = new MailMessage(listGlobalAttributes.Where(s => s.Name == "from").FirstOrDefault().Value, listGlobalAttributes.Where(s => s.Name == "to").FirstOrDefault().Value); //mail.Attachments.Add(new Attachment(slImagePath)); mail.Subject = "Nuevo Mensaje"; mail.Body = sbBody.ToString(); return CoreLibrary.CommonUtils.EmailOperations.SendEmail(mail, listGlobalAttributes); }
private void TicketOpenSendMail(Category EntCategory, Ticket lastTicket) { User entCurrenUser = (User)Session["currentUser"]; List<GlobalAttribute> listGlobalAttributes = new CoreLibrary.Configuration.Controller().GetConfiguration(entCurrenUser.IdApplication); string PortalAddress = string.Empty; PortalAddress = String.Format("{0}://{1}:{2}{3}", HttpContext.Current.Request.Url.Scheme, HttpContext.Current.Request.Url.Host, HttpContext.Current.Request.Url.Port, Request.ApplicationPath != "/" ? Request.ApplicationPath : ""); StringBuilder sbBody = new StringBuilder(); sbBody.AppendLine("<p>"); sbBody.AppendLine("<IMG src=\"Logo.jpg\"><br/>"); sbBody.AppendFormat("<strong>Ticket No: {0}</strong>", lastTicket.IdTicket); sbBody.AppendLine("<br/>"); sbBody.AppendFormat("<strong>Creado por: {0} el {1:d} </strong>", lastTicket.CreatedBy.UserCompleteName, lastTicket.CreatedOn); sbBody.AppendLine("<br/>"); sbBody.AppendLine("<strong>Descripción:</strong>"); sbBody.AppendFormat("<i>{0}</i>", lastTicket.Description); sbBody.AppendLine("<br/>"); sbBody.AppendLine(String.Format("Para cerrar el ticket da clic aqui:<a href=\"{0}/WT/Tickets/Close.aspx?IdTicket={1}\" >Cerrar Ticket</a>",PortalAddress, lastTicket.IdTicket)); sbBody.AppendLine("</p>"); string slImagePath = Server.MapPath(@"~/App_Themes/Default/Images/Logo.jpg"); MailMessage mail = new MailMessage(listGlobalAttributes.Where(s => s.Name == "from").FirstOrDefault().Value, EntCategory.DefaultMail); mail.Attachments.Add(new Attachment(slImagePath)); if (EntCategory.AlternativeMail != "") mail.To.Add(EntCategory.AlternativeMail); mail.Subject = "Ticket Abierto"; mail.Body = sbBody.ToString(); CoreLibrary.CommonUtils.EmailOperations.SendEmail(mail, listGlobalAttributes); }
private void TicketCloseSendMail(Category EntCategory, Ticket lastTicket) { User entCurrenUser = (User)Session["currentUser"]; List<GlobalAttribute> listGlobalAttributes = new CoreLibrary.Configuration.Controller().GetConfiguration(entCurrenUser.IdApplication); StringBuilder sbBody = new StringBuilder(); sbBody.AppendLine("<p>"); sbBody.AppendLine("<IMG src=\"Logo.jpg\"><br/>"); sbBody.AppendFormat("<strong>Ticket No: {0}</strong>", lastTicket.IdTicket); sbBody.AppendLine("<br/>"); sbBody.AppendFormat("<strong>Cerradp por: {0} el {1:d} </strong>", lastTicket.AssignedTo.UserCompleteName, lastTicket.ClosedOn); sbBody.AppendLine("<br/>"); sbBody.AppendLine("<strong>Descripción:</strong>"); sbBody.AppendFormat("<i>{0}</i>", lastTicket.Description); sbBody.AppendLine("<br/>"); sbBody.AppendLine("<strong>Descripción de Cierre:</strong>"); sbBody.AppendFormat("<i>{0}</i>", lastTicket.CloseDescription); sbBody.AppendLine("<br/>"); sbBody.AppendLine("</p>"); string slImagePath = Server.MapPath(@"~/App_Themes/Default/Images/Logo.jpg"); MailMessage mail = new MailMessage(listGlobalAttributes.Where(s => s.Name == "from").FirstOrDefault().Value, EntCategory.DefaultMail); //MailMessage mail = new MailMessage("*****@*****.**", EntCategory.DefaultMail); mail.Attachments.Add(new Attachment(slImagePath)); if (EntCategory.AlternativeMail != "") mail.To.Add(EntCategory.AlternativeMail); mail.Subject = "Ticket Cerrado"; mail.Body = sbBody.ToString(); CoreLibrary.CommonUtils.EmailOperations.SendEmail(mail, listGlobalAttributes); }
protected void btnForward_Click(object sender, EventArgs e) { List<GlobalAttribute> listGlobalAttributes = new CoreLibrary.Configuration.Controller().GetConfiguration(3); string PortalAddress = string.Empty; PortalAddress = String.Format("{0}://{1}:{2}{3}", HttpContext.Current.Request.Url.Scheme, HttpContext.Current.Request.Url.Host, HttpContext.Current.Request.Url.Port, Request.ApplicationPath != "/" ? Request.ApplicationPath : ""); string BuidMail = ""; #region Replace Template Content BuidMail = String.Format(ForwardMailTemplate, lblCreatedOnDate.Text, tbxName.Text, tbxeMail.Text, tbxCompanyWorking.Text, rblSecurityAnswer.SelectedValue, rblCompanyOpinionRating.SelectedValue, rblSupervisorRating.SelectedValue, rblGroupDirectorRating.SelectedValue, rblWorkEnviromentRating.SelectedValue, tbxSubject.Text, tbxComment.Text); //string ReplaceFor = ""; //string ReplaceRB = ""; //if (rblSecurityAnswer.SelectedValue != "") //{ // ReplaceFor = String.Format(@"name=""rblSecurityAnswer"" value=""{0}"" checked=""checked""/>", rblSecurityAnswer.SelectedValue); // ReplaceRB = String.Format(@"name=""rblSecurityAnswer"" value=""{0}"" />", rblSecurityAnswer.SelectedValue); // BuidMail = BuidMail.Replace(ReplaceRB, ReplaceFor); //} //if (rblCompanyOpinionRating.SelectedValue != "") //{ // ReplaceFor = String.Format(@"name=""rblCompanyOpinionRating"" value=""{0}"" checked=""checked""/>", rblCompanyOpinionRating.SelectedValue); // ReplaceRB = String.Format(@"name=""rblCompanyOpinionRating"" value=""{0}"" />", rblCompanyOpinionRating.SelectedValue); // BuidMail = BuidMail.Replace(ReplaceRB, ReplaceFor); //} //if (rblSupervisorRating.SelectedValue != "") //{ // ReplaceFor = String.Format(@"name=""rblSupervisorRating"" value=""{0}"" checked=""checked""/>", rblSupervisorRating.SelectedValue); // ReplaceRB = String.Format(@"name=""rblSupervisorRating"" value=""{0}"" />", rblSupervisorRating.SelectedValue); // BuidMail = BuidMail.Replace(ReplaceRB, ReplaceFor); //} //if (rblGroupDirectorRating.SelectedValue != "") //{ // ReplaceFor = String.Format(@"name=""rblGroupDirectorRating"" value=""{0}"" checked=""checked""/>", rblGroupDirectorRating.SelectedValue); // ReplaceRB = String.Format(@"name=""rblGroupDirectorRating"" value=""{0}"" />", rblGroupDirectorRating.SelectedValue); // BuidMail = BuidMail.Replace(ReplaceRB, ReplaceFor); //} //if (rblWorkEnviromentRating.SelectedValue != "") //{ // ReplaceFor = String.Format(@"name=""rblWorkEnviromentRating"" value=""{0}"" checked=""checked""/>", rblWorkEnviromentRating.SelectedValue); // ReplaceRB = String.Format(@"name=""rblWorkEnviromentRating"" value=""{0}"" />", rblWorkEnviromentRating.SelectedValue); // BuidMail = BuidMail.Replace(ReplaceRB, ReplaceFor); //} #endregion StringBuilder sbBody = new StringBuilder(); sbBody.AppendLine("<p>"); //sbBody.AppendLine("<IMG src=\"Logo.jpg\"><br/>"); sbBody.AppendLine("<br/>"); sbBody.AppendLine(BuidMail); //sbBody.AppendLine(String.Format("Para ver la información da clic aqui:<a href=\"{0}/LoginPage.aspx\" >Ingresar</a>", PortalAddress)); sbBody.AppendLine("</p>"); //string slImagePath = Server.MapPath(@"~/App_Themes/Default/Images/Logo.jpg"); MailMessage mail = new MailMessage(); mail.From = new MailAddress(listGlobalAttributes.Where(s => s.Name == "from").FirstOrDefault().Value); string[] eMails = tbxForward.Text.Split(';').ToArray(); foreach (string sleMail in eMails) { string email = sleMail; email = email.Replace("\r", ""); email = email.Replace("\n", ""); email = email.Replace("\t", ""); mail.To.Add(email); } //mail.Attachments.Add(new Attachment(slImagePath)); mail.Subject = "Rv: Mensaje"; mail.Body = sbBody.ToString(); if(CoreLibrary.CommonUtils.EmailOperations.SendEmail(mail, listGlobalAttributes)) ScriptManager.RegisterStartupScript(this, this.GetType(), "GlobalAttributes", " alert('La información se envio por email correctamente.');", true); }