public static string GenerateHtml(SessionDataBLL Obj) { using (var dbContext = new BSSDBEntities()) { var ReqData = dbContext.SP_StatusWiseCompleteReport(Obj.DealerID, Obj.AccountId).ToList(); string Html = "<!DOCTYPE html><html><head><style>table, th, td {border: 1px solid black;border-collapse: collapse;}</style></head><body><br /> <label>Please find attachment for group wise report. Status wise report is Shown below :-</label><br /><br /><table><thead><tr><th>Status Name:</th><th>No. Of JobCards</th></tr></thead>"; Html = Html + "<tbody>"; foreach (var data in ReqData) { Html = Html + "<tr><td>" + data.StatusName + "</td><td>" + data.NoOfJobCards + "</td></tr>"; } Html = Html + "</tbody></table><br /><br />"; Html = Html + "<label>Regards,</label><br /><label>BodyShop Application</label><br /><br />"; Html = Html + "<label>This is an auto generated mail, Do not reply</label><br /></body></html>"; return(Html); } }