本文介绍了如何在asp.net中发送电子邮件HTML正文格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试以html正文格式发送电子邮件,但是它不起作用.
我正在使用"System.Net.Mail"命名空间,并且还将MailMessage属性IsBOdyHtml设置为true.

I am try to send email in html body format but it not working.
I am using "System.Net.Mail" namespace and i also set MailMessage property IsBOdyHtml true.

推荐答案

string text= "<table><tr><td>EmpId</td><td>Emp name</td><td>age</td></tr><tr><td>value</td><td>value</td><td>value</td></tr></table>"
MailMessage mail = new MailMessage();
mail.To ="[email protected]";
mail.From = "[email protected]";
mail.Subject = "this is a test email.";
mail.IsBodyHtml=true;
mail.Body = text;
MailAttachment attachment = new MailAttachment( Server.MapPath( "test.txt" ) );
mail.Attachments.Add( attachment );	//add the attachment
SmtpMail.SmtpServer = "smtp.gmail.com";  //your real server goes hereSmtpMail.Send( mail );



<pre lang="c++">><


这篇关于如何在asp.net中发送电子邮件HTML正文格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 01:59