Use C # To send custom html emails,
To send an HTML-formatted email, set the IsBodyHtml attribute of the MailMessage object to true.
The MailMessage class is in the namespace System. Net. Mail.
Using System. Net. Mail;
Emails in HTML format have been implemented in the HoverTreeTop project and sent successfully.
It depends on the HoverTreeFrame project's HoverTreeEmail class.
Method:
Public static string HoverTreeSendEmail (string userName, string password, SmtpClient smtpClient, MailMessage mailMessage)
Page:
EmailSend. aspx page:
<H2> send email
EmailSend. aspx. cs code:
Using System; using System. net. mail; using HoverTree. hoverTreeFrame. htNet; using HoverTreeTop. htConfig. myConfig; namespace HoverTreeTop. hoverTree. hoverTreePanel. HTPanel. HEmail {public partial class EmailSend: System. web. UI. page {protected void Page_Load (object sender, EventArgs e) {} protected void button_send_Click (object sender, EventArgs e) {// use smtp to send emails // literal_tips.Text = HoverTreeEmail. hov ErTreeSendEmail ("smtp.hovertree.com", "hello @ .mail.hovertree.com", "hewenqi", "hello@mail.hovertree.com", "ht@mail.hovertree.com", "Happy birthday to you! "," Happy Birthday! Happy every day! -- He asked "); // literal_tips.Text = HoverTreeEmail. hoverTreeSendEmail (HtSmtpConfig. htSmtpHost, HtSmtpConfig. htSmtpUserName, HtSmtpConfig. htSmtpPassword, HtSmtpConfig. htSmtpFromEmail, delimiter (), textBox_title.Text, textBox_content.Text); SmtpClient h_smtpClient = new SmtpClient (); h_smtpClient.Host = HtSmtpConfig. htSmtpHost; MailMessage h_mailMessage = new MailMessage (); h_mailMessage.F Rom = new MailAddress (HtSmtpConfig. htSmtpFromEmail); h_mailMessage.To.Add (Response (); h_mailMessage.Subject = Response (); h_mailMessage.Body = textBox_content.Text; response = checkBox_isHtml.Checked; response = HoverTreeEmail. hoverTreeSendEmail (HtSmtpConfig. htSmtpUserName, HtSmtpConfig. htSmtpPassword, h_smtpClient, h_mailMessage); if (literal _ Tips. Text = "") {literal_tips.Text = "sent successfully! "; TextBox_content.Text =" "; textBox_title.Text =" "; textBox_mail.Text = "";}}}}
Sample content for sending:
<Html> <body>
Reference: http://hovertree.com/h/bjag/swth6nfh.htm
Code download: http://hovertree.com/h/bjaf/hv6cqe5n.htm
More recommendations: http://www.cnblogs.com/sosoft/p/kaifajishu.html