Hi
I have below code & displaying like normal string in Body of Email
StringBuilder htmlTable = new StringBuilder();
//htmlTable.Append("");
htmlTable.Append("");
htmlTable.Append("");
// Add headers to the table
htmlTable.Append("");
htmlTable.Append("Transaction ID ");
htmlTable.Append("Doc. No ");
htmlTable.Append("Doc. Date ");
htmlTable.Append(" ");
while (!oRecordSet.EoF)
{
htmlTable.Append("");
htmlTable.Append("" + oRecordSet.Fields.Item("TransId").Value.ToString() + " ");
htmlTable.Append("" + oRecordSet.Fields.Item("DocNum").Value.ToString() + " ");
htmlTable.Append("" + oRecordSet.Fields.Item("DocDate").Value.ToString() + " ");
htmlTable.Append(" ");
oRecordSet.MoveNext();
}
htmlTable.Append("
");
string body = htmlTable.ToString();
*************************************************************************
Transaction ID Doc. No Doc. Date 1655069 5107214 1/8/2025 12:00:00 AM 1655912 5107222 1/8/2025 12:00:00 AM 210971 4700072 5/11/2024 12:00:00 AM 212022 4700073 5/11/2024 12:00:00 AM 825928 1004586 4000072 9/6/2024 12:00:00 AM 1134530 4000078 9/27/2024 12:00:00 AM
Thanks
1 Reply
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Muhammad Imran AnsariPosted Feb 7, 2025, 7:01 AM
Hello Ramco,
The issue you're facing is likely due to the email client not rendering the HTML correctly or the
IsBodyHtmlproperty not being set totruein theMailMessageobject. WithoutIsBodyHtml = true, the email client will treat the content as plain text, and the HTML tags will be displayed as a normal string instead of being rendered as a table.Here’s how you can fix the issue and ensure the HTML table is displayed correctly in the email body: