Asp.net中的HTML格式邮件 [英] HTML format mail in Asp.net

查看:81
本文介绍了Asp.net中的HTML格式邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我已使用以下代码发送html格式的电子邮件

Hi I have used the code below to send the html formatted email

MailMessage message = new MailMessage();
            message.From = new MailAddress("mymail@gmail.com");
            message.To.Add(new MailAddress("anyone@gmail.com"));
            message.Subject = "test mail";
            string msg;
            msg = "<b>Hi</b> "+ "George" + "<br /><b>Hw r u</b> ";
            message.Body = msg;
            SmtpClient client = new SmtpClient();
            client.Credentials = new System.Net.NetworkCredential("mymail@gmail.com", "xxxxxxx");
            client.Port = 587;
            client.Host = "smtp.gmail.com";
            client.EnableSsl = true;
            client.Send(message);



但是问题是当我收到的消息被拒绝时是这样的:



BUT the problem is when i the message recieved it delievered as it is:

<b>Hi</b>George<br /><b>Hw r u/b>



请帮我解决上面的代码



please help me with the above code

推荐答案

我猜你必须设置
I''m guessing you would have to set the MailMessage.IsBodyHtml Property[^] to true, in order to let the mail client know that the message should be displayed as HTML instead of raw text.
message.IsBodyHtml = true;


我不确定这是否可以解决问题,请尝试一下.


I''m not sure if this solves the problem, but give it a try.


这篇关于Asp.net中的HTML格式邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆