public JsonResult SendMail(string Lab, string testid) { var tosend = "*****@*****.**"; string path = ""; PatientLabReportPrint rptPatientLabReports = new PatientLabReportPrint(); DataSet ds = BL_obj.SendMail(Lab, testid); List <PatientLabReportPrint> searchlist = new List <PatientLabReportPrint>(); foreach (DataRow dr in ds.Tables[0].Rows) { searchlist.Add(new PatientLabReportPrint { EmailID = dr["EmailID"].ToString(), EmailPassword = dr["EmailPassword"].ToString() }); } ReportDocument crystalReport = new ReportDocument(); // creating object of crystal report crystalReport.Load(Path.Combine(Server.MapPath("~/Report"), "RptPatientLabReports.rpt")); // path of report crystalReport.SetDataSource(ds); // binding datatable //SetDataSource(ds); int email1 = 0; string hospitalname = ds.Tables[0].Rows[0]["HospitalName"].ToString(); string patname = ds.Tables[1].Rows[0]["PatientName"].ToString(); path = "c:\\LabReports" + "ss" + ".pdf"; email1++; //CrystalDecisions.Shared.ExportOptions CrExportOptions; CrystalDecisions.Shared.DiskFileDestinationOptions CrDiskFileDestinationOptions = new CrystalDecisions.Shared.DiskFileDestinationOptions(); CrystalDecisions.Shared.PdfRtfWordFormatOptions CrFormatTypeOptions = new CrystalDecisions.Shared.PdfRtfWordFormatOptions(); var filename = Path.GetFileName(crystalReport.FileName); var extention = Path.GetExtension(crystalReport.FileName); var filenamethoutextenction = Path.GetFileNameWithoutExtension(crystalReport.FileName); CrDiskFileDestinationOptions.DiskFileName = crystalReport.FileName; //CrExportOptions = rptPatientLabReports.ExportOptions; //{ // CrExportOptions.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile; // CrExportOptions.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat; // CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions; // CrExportOptions.FormatOptions = CrFormatTypeOptions; //} //rptPatientLabReports.Export(); email1++; string email = ds.Tables[0].Rows[0]["EmailID"].ToString(); string pass = ds.Tables[0].Rows[0]["EmailPassword"].ToString(); System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage(); SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com"); mail.From = new MailAddress(email); mail.To.Add("*****@*****.**"); // mail.Subject = txtSubject.Text; mail.Attachments.Add(new Attachment(@"C:\Users\Saurabh\Downloads\Nilesh (1).pdf")); SmtpServer.Port = 587; SmtpServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", "saurabh@123"); SmtpServer.EnableSsl = true; SmtpServer.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network; SmtpServer.UseDefaultCredentials = false; SmtpServer.Send(mail); bool result = false; return(Json(result, JsonRequestBehavior.AllowGet)); }
public JsonResult GetAllShowPatientLabReports(string FromDate, string ToDate, string PatientRegNo, string LabNo, string DoctorID) { PatientLabReportPrint obj = new PatientLabReportPrint(); string CategoryID = Request.Form["CategoryID"]; if (CategoryID == "") { obj.CategoryID = ""; } else { obj.CategoryID = CategoryID; } string DepartmentID = Request.Form["DepartmentID"]; if (DepartmentID == "") { obj.DepartmentID = ""; } else { obj.DepartmentID = DepartmentID; } if (PatientRegNo == "") { PatientRegNo = "%"; } if (LabNo == "") { LabNo = "%"; } if (DoctorID == "") { DoctorID = "%"; } obj.FromDate = FromDate; obj.ToDate = ToDate; DataSet ds = BL_obj.GetAllPatientLabReports(FromDate, ToDate, PatientRegNo, LabNo, DoctorID); List <PatientLabReportPrint> searchlist = new List <PatientLabReportPrint>(); foreach (DataRow dr in ds.Tables[0].Rows) { searchlist.Add(new PatientLabReportPrint { LabNo = dr["LabNo"].ToString(), PatientName = dr["PatientName"].ToString(), LabDate = dr["LabDate"].ToString(), LabType = dr["LabType"].ToString(), DoctorName = dr["DoctorName"].ToString() }); } return(new JsonResult { Data = searchlist, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }