private void SendNotification(string surveyId, string responseId) { StringBuilder Body = new StringBuilder(); string Sender = ConfigurationManager.AppSettings["EMAIL_FROM"].ToString(); string Subject = "Epi Info Response Submission Notification"; List <PrintResponseModel> list = GetResponseList(responseId, true); int NumberOfPages = list[0].NumberOfPages; Body.Append("Thank you for using Epi info web survey to submit your response to: " + list[0].SurveyName + "<br/>"); // Body.Append(" <style>.table, th, td { border: 1px solid black;}</style>"); Body.Append("<style>.table { font-family: 'Trebuchet MS', Arial, Helvetica, sans-serif;border-collapse: collapse;width:90%;}.table td, #customers th {border: 1px solid #ddd; padding: 8px;} .table tr:nth-child(even){background-color: #f2f2f2;} .table tr:hover {background-color: #ddd;} .table th { padding-top: 12px;padding-bottom: 12px;text-align: left;background-color: #2f6fa3;color: white;}</style>"); for (int i = 1; NumberOfPages + 1 > i; i++) { Body.Append(GetEmailInfo(list[0].ResponseList.Where(m => m.PageNumber == i).ToList(), i)); Body.Append("<br/> "); } try { Epi.Web.Common.Email.Email EmailObj = new Common.Email.Email(); EmailObj.Body = Body.ToString(); EmailObj.From = Sender; EmailObj.Subject = Uri.UnescapeDataString(Subject); EmailObj.To = EmailAddressList; bool EmailSent = Epi.Web.Common.Email.EmailHandler.SendMessage(EmailObj); } catch (Exception ex) { throw ex; } }
public JsonResult Notify(string emailAddress, string redirectUrl, string surveyName, string passCode, string emailSubject) { try { if (redirectUrl.Contains("&IsSaved=True")) { redirectUrl = redirectUrl.Replace("&IsSaved=True", ""); } if (redirectUrl.Contains("&IsSaved=False")) { redirectUrl = redirectUrl.Replace("&IsSaved=False", ""); } Epi.Web.Common.Email.Email EmailObj = new Common.Email.Email(); EmailObj.Body = redirectUrl + " and Pass Code is: " + passCode; EmailObj.From = ConfigurationManager.AppSettings["EMAIL_FROM"].ToString(); EmailObj.Subject = Uri.UnescapeDataString(emailSubject); List <string> tempList = new List <string>(); tempList.Add(emailAddress); EmailObj.To = tempList; if (Epi.Web.Common.Email.EmailHandler.SendMessage(EmailObj)) { return(Json(true)); } else { return(Json(false)); } } catch (Exception ex) { return(Json(false)); } }