Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am sending a mail with HTML Body in asp.net. But matter is that in mail the Body message doesn't show data in Table.But i am using Table in HTML body. It looks like this :

<br />
Name = ABC<br />
Last Name = xxx<br />
E-Mail = 0000<br />
Contact = 0000<br />
Description = 00000xxxx<br />


But I want this format comes in a Proper Table with border.

Please check below & give me suggetion...

C#
string strBody = "<html><body><table><tr><td>Name = </td><td>" + name + "</td></tr> " +
                  " <tr><td>Contact No. = </td><td>" + mobile + "</td></tr> " +
                 " <tr><td>Email-ID = </td><td>" + email + "</td></tr> " +
                 " <tr><td>City = </td><td>" + city + "</td></tr> " +
                 " <tr><td>State = </td><td>" + state + "</td></tr> " +
                 " <tr><td>Country = </td><td>" + country + "</td></tr><br /> " +
                 " <tr><td>Message = </td><td>" + body + "</td></tr> " +
                 " </table> </body></html>";
message.Body=strBody;
message.IsBodyHtml = true;
Posted
Updated 28-Jun-12 19:17pm
v3

C#
string strBody = "<html><body><table border="2"><tr><td>Name = </td><td>" + name + "</td></tr> " +
                  " <tr><td>Contact No. = </td><td>" + mobile + "</td></tr> " +
                 " <tr><td>Email-ID = </td><td>" + email + "</td></tr> " +
                 " <tr><td>City = </td><td>" + city + "</td></tr> " +
                 " <tr><td>State = </td><td>" + state + "</td></tr> " +
                 " <tr><td>Country = </td><td>" + country + "</td></tr><br /> " +
                 " <tr><td>Message = </td><td>" + body + "</td></tr> " +
                 " </table> </body></html>";
 
message.Body=strBody;
message.IsBodyHtml = true;
 
Share this answer
 
Comments
Mas11 29-Jun-12 1:34am    
Thanks for answer but it doesn't work.
Mas11 29-Jun-12 1:38am    
Sorry my bro.. Wonderfull.. It worked.. Really i am smiling.. Again Thanks a lot..
Sushil Mate 29-Jun-12 1:52am    
Don't be sorry :) WC
try using this..you will see in your mail that whether in mail table is created or not

C#
string strBody = "<table border='1' width='500px'><tr><td>Name =</td><td>" + name + "</td></tr><tr><td>Contact No. =</td><td>" + mobile + "</td></tr><tr><td>Email-ID =</td><td>" + email + "</td></tr><tr><td>City =</td><td>" + city + "</td></tr><tr><td>State =</td><td>" + state + "</td></tr><tr><td>Country =</td><td>" + country + "</td></tr><tr><td>Message =</td><td>" + body + "</td></tr></table>";
 
Share this answer
 
v3
Comments
Mas11 29-Jun-12 1:34am    
It Doesn't work ashish !!
AshishChaudha 29-Jun-12 1:37am    
sorry i improved my solution..in which format you are getting the mail..could you show us please.
Mas11 29-Jun-12 1:39am    
Thanks a lot for your reply bro !!
Mas11 29-Jun-12 1:40am    
Yes.. Now its exact solution !!
AshishChaudha 29-Jun-12 1:42am    
why don't you mark it as a solution if you got your anwer..so that other's can refer..Thanks..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900