Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C# email
I have a email with body . i want to have a html page embedded inside the mail body , and my html page will have some links and textbox to search and navigate .
Any suggestions please.
Posted 27-Dec-12 17:39pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You can put HTML inside a message body, just wrap it in HTML tags.
However, you should know that you probably won't get the behavior you desire. There are a number of popular email clients out there and they all handle messages differently. Many will only display the message as text and will ignore anything wrapped in HTML tags. Many that will display HTML are likely to block image downloads for images in the HTML by default (it is a privacy hole). You are likely to find that most clients will also block any active components by default (such as flash), scripting, and probably POST operations as well. Email clients usually (and rightfully) distrust email content and try to keep it in a sandbox. This really limits what you can and can't do. It has been used as an attack vector so many times, nobody trusts email any more.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

string v_sendMailUserName = "userName";//
string v_sendMailPassword = "userPwd";//
string v_sendMailAddress ="";//
string v_receiveMailAddress ="";//
string v_mailSubject = "";//

SmtpClient smtp = new SmtpClient(v_smtpAddress);
smtp.Credentials = new System.Net.NetworkCredential(v_sendMailUserName, v_sendMailPassword);
MailMessage mes = new MailMessage();

mes.From = new MailAddress(v_sendMailAddress);

mes.Subject = v_mailSubject;
mes.Body = @"<html>

this is test!

mes.IsBodyHtml = true;//set html format
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

Here is a sample : Email Templates[^].
And also you can use MailDefinition Class[^] to make interactive HTML mail body.
For more referances see:
How to Send HTML Page As Email Body in Asp.Net Using C#.NET,VB.NET[^]
Sending Email in ASP.NET 2.0: HTML-Formatted Emails, Attachments, and Gracefully Handling SMTP Exceptions[^]
Hope it helps.

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 881
1 OriginalGriff 270
2 Volynsky Alex 205
3 CPallini 180
4 Richard Deeming 175
0 OriginalGriff 5,640
1 Sergey Alexandrovich Kryukov 4,693
2 CPallini 4,540
3 George Jonsson 3,132
4 Gihan Liyanage 2,445

Advertise | Privacy | Mobile
Web03 | 2.8.140916.1 | Last Updated 28 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100