惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Tailwind CSS Blog
大猫的无限游戏
大猫的无限游戏
L
LINUX DO - 热门话题
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
雷峰网
雷峰网
aimingoo的专栏
aimingoo的专栏
博客园_首页
MongoDB | Blog
MongoDB | Blog
V
V2EX
GbyAI
GbyAI
量子位
Microsoft Azure Blog
Microsoft Azure Blog
有赞技术团队
有赞技术团队
G
Google Developers Blog
云风的 BLOG
云风的 BLOG
B
Blog
Microsoft Security Blog
Microsoft Security Blog
S
SegmentFault 最新的问题
O
OpenAI News
N
News and Events Feed by Topic
博客园 - Franky
爱范儿
爱范儿
Forbes - Security
Forbes - Security
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
V2EX - 技术
V2EX - 技术
Application and Cybersecurity Blog
Application and Cybersecurity Blog
N
News and Events Feed by Topic
N
News | PayPal Newsroom
Schneier on Security
Schneier on Security
Cloudbric
Cloudbric
Security Archives - TechRepublic
Security Archives - TechRepublic
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Recent Commits to openclaw:main
Recent Commits to openclaw:main
人人都是产品经理
人人都是产品经理
P
Privacy International News Feed
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
B
Blog RSS Feed
阮一峰的网络日志
阮一峰的网络日志
D
DataBreaches.Net
Last Week in AI
Last Week in AI
罗磊的独立博客
Spread Privacy
Spread Privacy
Recent Announcements
Recent Announcements
The Cloudflare Blog
Google DeepMind News
Google DeepMind News
AWS News Blog
AWS News Blog
The Register - Security
The Register - Security
Y
Y Combinator Blog
J
Java Code Geeks
I
Intezer

博客园 - 绿叶

Suspicions about the new platform dynamic sorting expression builder How to create your own api with ACL in Magento 台服信长之野望全后台辅助外挂 SEO Elite ver 4.0 R93 Patcher Remove 5 seconds constraint in Garena(GGC) - 绿叶 Robot development framework in Mush Client (Lua) 巧用Marshal.GetDelegateForFunctionPointer--C#如何调用按键精灵插件dll Using .Net, Flex, and Red5 to create a flash web application 做了个C#的Hotkey简单封装,希望对大家有帮助 功夫世界外挂发布测试 我的第一个全后台CALL外挂-功夫世界外挂 通过修改Mutex来达到大航海OL多开 如何利用WPE对大航海Online进行港内瞬移,瞬时生产和快速进港 MonoRail PetShop Source Code Released MS PetShop3 -> MonoRail PetShop 完成移植 移植MSPetShop3到Castle MonoRail -Model与DAL层的移植(AR) 对 "闭包-closure" 的一些见解 圈内Castle文章索引
利用Castle Framework发email是如此easy
绿叶 · 2006-03-08 · via 博客园 - 绿叶

        最近要在项目中发送对用户发送各种各样的邀请函,项目是使用castle作为框架的。发现castle中的一个Component(email sender)是封装了System.Web.Mail,而framework再对这个Component封装,从而使他email支持模板,废话少说,看具体用法吧:

配置:
        1.在web.config中的配置smtp的几个简单参数:

<monoRail smtpHost="host name" smtpUsername="username" smtpPassword="password">
.
</monoRail>

        2.在views目录下建个mail目录,放email模板,比如:(invitation.vm)

from:$from
to:$to
subject:$subject
<html>
<head>
<title>邀请函</title>
</head>
<body>
$name 邀请你XXXXX
</body>
</html>

        3.先用PropertyBag.Add模板的的参数,比如:PropertyBag.Add("from", "wjshome#gmail.com")

        4.使用RenderMailMessage("invitation")函数获取一个Message对象
这里你可以更改他的encording,中文可以设置成"gb2312"。
还可以更改message的format,做format时,框架已经自动帮你处理了,如果检测到模板中包含<html>,则自动把format设置成html格式。

        5.用DeliverEmail(message)发送。

        6.如果你不用设置Message对象的参数的话,你可以直接用RenderEmailAndSend("invitaion")替代第4.5步。

呵呵~完了,简单吧,有兴趣的去试试~~