tags:

views:

402

answers:

3

How do i send an html email? I use this code to send emails http://stackoverflow.com/questions/704636/sending-email-through-gmail-smtp-server-with-c/707892#707892

When i sent myself an email i got this all in text instead of a clickable link. However gmail does make urls clickable so i get the link twice and no html formating. How do i make put html formatting in my emails?

<p>Welcome to SiteName. To activate your account visit this url <a href="http://SiteName.com/a?key=1234"&gt;http://SiteName.com/a?key=1234&lt;/a&gt;&lt;/p&gt;
+2  A: 

Apply the correct encoding of the Mailbody.

mail.IsBodyHtml = true;
Bdiem
+1  A: 

I believe it was something like:

mailObject.IsBodyHtml = true;
Ropstah
ropstah: TBH i was confused and wrote in one of the two comments that there is no IsBodyHtml in SmtpClient. Josiah is who showed me to do it with MailMessage.
acidzombie24
+7  A: 

This is what I do:

MailMessage mail = new MailMessage(from, to, subject, message);
mail.IsBodyHtml = true;
SmtpClient client = new SmtpClient("localhost");
client.Send(mail);

Note that I set the mail message html to true: mail.IsBodyHtml = true;

Josiah Peters