protected void SendMailOnFlagSave(int Allotment_ID, int Vessel_ID, string PBill_Date, int CrewID) { Table tblFlag = new Table(); TableRow R1flg = new TableRow(); TableCell CL1flg = new TableCell(); TableRow R2flg = new TableRow(); TableCell CL2flg = new TableCell(); R1flg.Cells.Add(CL1flg); R2flg.Cells.Add(CL2flg); tblFlag.Rows.Add(R1flg); tblFlag.Rows.Add(R2flg); DateTime dtDate = Convert.ToDateTime(PBill_Date); frmvCrewDetails.DataSource = BLL_PB_PortageBill.Get_Allotments(int.Parse(ddlFleet.SelectedValue), int.Parse(ddlVessel.SelectedValue), ViewState["PBMonth"].ToString(), ViewState["PBYear"].ToString(), int.Parse(ddlApproval.SelectedValue), int.Parse(DDLBank.SelectedValue), int.Parse(ddlStatus.SelectedValue), txtSearch.Text, Convert.ToInt32(hdfCrewIDFlag.Value), null, AllotmentID); frmvCrewDetails.DataBind(); (frmvCrewDetails.FindControl("btnVerifyAllot") as Button).Visible = false; DataSet dsRmk = BLL_PB_PortageBill.ACC_GET_Allotment_Flag(Allotment_ID, Vessel_ID, dtDate); GridView gvFlag = new GridView(); gvFlag.HeaderStyle.CssClass = "CreateHtmlTableFromDataTable-DataHedaer"; gvFlag.RowStyle.CssClass = "CreateHtmlTableFromDataTable-Data"; gvFlag.AutoGenerateColumns = false; gvFlag.DataKeyNames = new string[] { "Flag_ID" }; gvFlag.BorderWidth = 1; gvFlag.Width = 498; BoundField User = new BoundField(); User.DataField = "CreatedBy"; User.HeaderText = "User"; BoundField Date = new BoundField(); Date.DataField = "CreatedOn"; Date.HeaderText = "Date"; BoundField Message = new BoundField(); Message.DataField = "Remark"; Message.HeaderText = "Message"; BoundField Attachcol = new BoundField(); Attachcol.DataField = "CreatedBy"; Attachcol.HeaderText = "Attachments"; gvFlag.Columns.Add(User); gvFlag.Columns.Add(Date); gvFlag.Columns.Add(Message); gvFlag.Columns.Add(Attachcol); gvFlag.DataSource = dsRmk.Tables[0]; gvFlag.DataBind(); foreach (GridViewRow gr in gvFlag.Rows) { GridView gvAttach = new GridView(); gvAttach.AutoGenerateColumns = false; gvAttach.BorderWidth = 0; gvAttach.ShowHeader = false; gvAttach.RowStyle.CssClass = "CreateHtmlTableFromDataTable-Data-Attachment"; HyperLinkField LinkAttch = new HyperLinkField(); LinkAttch.DataNavigateUrlFields = new string[] { "Attachment_Path" }; LinkAttch.DataTextField = "Attachment_Name"; LinkAttch.Target = "blank"; gvAttach.Columns.Add(LinkAttch); gvAttach.DataSource = dsRmk.Tables[1].AsEnumerable().Where(a => a["Flag_ID"].ToString().Equals(gvFlag.DataKeys[gr.RowIndex].Values["Flag_ID"].ToString())).AsDataView().ToTable(); gvAttach.DataBind(); gr.Cells[3].Text = ""; gr.Cells[3].Controls.Add(gvAttach); } CL1flg.Controls.Add(frmvCrewDetails); CL2flg.Controls.Add(gvFlag); System.IO.StringWriter stringWrite = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWriter(stringWrite); tblFlag.RenderControl(htmlWrite); string mailContent = htmlWrite.InnerWriter.ToString(); string mailBody = "<html><head> <style type='text/css'> body { font-size: 11px;font-family: Tahoma ,Tahoma, Sans-Serif; } .CreateHtmlTableFromDataTable-PageHeader { background-color: #F6B680; } .CreateHtmlTableFromDataTable-DataHedaer { background-color: #F2F2F2; border: 1px solid gray; text-align: center; } .CreateHtmlTableFromDataTable-Data{ border: 1px solid gray; } </style> </head> <body > <table style='width:500px;background-color: #FFFFFF;border: 2px solid #FFB733;' border='1' ><tr><td>" + mailContent + "</td> </tr> </table> </body></html>"; string sToEmailAddress = BLL_PB_PortageBill.ACC_Get_Allotment_Flag_Mail(Convert.ToInt32(Session["userid"])); BLL_Crew_CrewDetails objMail = new BLL_Crew_CrewDetails(); objMail.Send_CrewNotification(0, 0, 0, 0, sToEmailAddress, "", "", "Allotment Flag", mailBody, "", "MAIL", "", UDFLib.ConvertToInteger(Session["USERID"].ToString()), "READY"); }