如何在asp.net中发送电子邮件HTML正文格式 [英] How to send email html body format in asp.net
本文介绍了如何在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.
推荐答案
将IsBodyHTMl设置为true后,您必须使正文HTML检查代码
Hi,
After setting IsBodyHTMl true,you''ll have to make the body HTML check the code
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 ="me@mycompany.com";
mail.From = "you@yourcompany.com";
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 );
尝试一下.
(ASP.NET)使用SMTP以HTML格式使用web.config文件中的IP设置发送邮件 [ ^ ]
try this one.
(ASP.NET)Sending mail using SMTP in HTML format using IP settings in web.config file[^]
<pre lang="c++">><
这篇关于如何在asp.net中发送电子邮件HTML正文格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文