Click here to Skip to main content
15,901,505 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i am sending Mail Then Send Table like this td>Hello


But I Need like ---Hello
Not table Structure..

What I have tried:

C#
MailAddress to = new MailAddress(email);
                //sender email address
                MailAddress from = new MailAddress("xyz@gmail.com.com");

                MailMessage msg = new MailMessage();
                //use reason shown in grid
                msg.Subject = "Hello This For Test";



               string textBody = "<table border=" + 1 + " cellpadding=" + 0 + " cellspacing=" + 0 + " width=" + 400 + "><tbody><tr><td>Name:'"+name.Text+"'</td> <td> Email:'"+email+"'  </td><td>ContactNo:'"+contactNo.Text+"'</td></tr></tbody></table>";
                msg.Body = textbody;
                msg.From = from;
                msg.To.Add(to);

            SmtpClient client = new SmtpClient();
        client.Host = "smtpout.secureserver.net";
        client.Port = 25;
        client.EnableSsl = true;
        client.Credentials = new System.Net.NetworkCredential("xyz@gmail.com", "01234");

        try
        {
            client.Send(mail);
        }
        catch (Exception ex)
        {
            Console.WriteLine("{0} Exception caught.", ex);
        }
Posted
Updated 22-Dec-18 10:05am
v2
Comments
MadMyche 21-Dec-18 9:19am    
If you don't want a table structure.... why are you defining textBody with a table in it?
Er.RajeshKumar 26-Dec-18 6:09am    
I need table data Not Structure ..
solution of the problem
msg.IsBodyHTML=true;
Bryian Tan 21-Dec-18 10:07am    
Sound like you want table in the email. Have you try client.IsBodyHtml = true; ?
Er.RajeshKumar 26-Dec-18 6:10am    
Thaanx client.IsBodyhtml=true;
working
Bryian Tan 26-Dec-18 10:28am    
You’re welcome

1 solution

If you are using System.Web.Mail Assembly try using System.Net.Mail it has a option to set your message body as HTML.

MailMessage msg = new MailMessage();
msg.IsBodyHTML=true;
 
Share this answer
 
v6
Comments
Er.RajeshKumar 23-Dec-18 23:22pm    
thank you your Msg.IsbodyHtml is working my Table design proper send in Email..

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