Click here to Skip to main content
15,901,426 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I have used the code below to send the html formatted email
C#
MailMessage message = new MailMessage();
            message.From = new MailAddress("mymail@gmail.com");
            message.To.Add(new MailAddress("anyone@gmail.com"));
            message.Subject = "test mail";
            string msg;
            msg = "<b>Hi</b> "+ "George" + "<br /><b>Hw r u</b> ";
            message.Body = msg;
            SmtpClient client = new SmtpClient();
            client.Credentials = new System.Net.NetworkCredential("mymail@gmail.com", "xxxxxxx");
            client.Port = 587;
            client.Host = "smtp.gmail.com";
            client.EnableSsl = true;
            client.Send(message);


BUT the problem is when i the message recieved it delievered as it is:
<b>Hi</b>George<br /><b>Hw r u/b>


please help me with the above code
Posted
Updated 30-Jan-11 3:13am
v2

1 solution

I'm guessing you would have to set the MailMessage.IsBodyHtml Property[^] to true, in order to let the mail client know that the message should be displayed as HTML instead of raw text.
C#
message.IsBodyHtml = true;

I'm not sure if this solves the problem, but give it a try.
 
Share this answer
 
Comments
[no name] 30-Jan-11 9:21am    
same prob bro :)
[no name] 30-Jan-11 9:24am    
Yes bro that was missing. Had sum confusion thax a lot
Kristian Sixhøj 30-Jan-11 9:32am    
You're welcome :)
Abhinav S 30-Jan-11 12:34pm    
Good answer.

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