如何将值传递到HTML模板并将其作为电子邮件发送? [英] How to pass values to an HTML template and send it as an email?

查看:95
本文介绍了如何将值传递到HTML模板并将其作为电子邮件发送?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我需要创建一封新闻信并通过电子邮件发送.我知道如何通过电子邮件发送简单的文本消息,但是我需要新闻信函电子邮件采用HTML格式,包括样式和内容,就像代码项目新闻信函一样.我已经有了新闻信函的模板,并且我需要一种将值传递给模板以及如何通过电子邮件发送HTML文档的方法.

Hi,
I need to create a news letter and send it via email. I know how to send simple text messages via email but I need the news letter email to be in HTML format with styles and stuff, pretty much like the code project news letter. I already have template for the news letter and I need a way to pass values to the template and how to send that HTML document via email.

推荐答案

使用MailMessage类设置属性IsBodyHtml = true,然后将html包含为消息正文,也许在需要时使用string.format向其添加动态值.
Using the MailMessage class set the property IsBodyHtml = true then include the html as the message body, perhaps using string.format to add dynamic values to it where required.


这篇关于如何将值传递到HTML模板并将其作为电子邮件发送?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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