如何在Web配置文件中配置邮件设置
问题描述:
我必须在Web配置文件中配置smtp邮件设置,并想在页面后面的代码中调用它.
谢谢
莫哈末Wasif
Hi,
I have to configure smtp mail setting in web config file and want to call that in code behind of a page .
thanks
Mohd. Wasif
答
解决方案1)上面有一篇不错的文章.
http://www.4guysfromrolla.com/articles/072606-1.aspx [ ^ ]
解决方案2)您可以按以下方式在web.config中添加密钥
Solution 1) there is a good article on it.
http://www.4guysfromrolla.com/articles/072606-1.aspx[^]
Solution 2) you can add your keys in web.config as follows
<appSettings>
<add key="ServerAdd" value="172.101.50.10" />
<add key="Port" value="25" />
<add key="FromEmail" value="abc@abcd.com" />
</appSettings>
稍后您可以在下面的代码中进行访问
which later you can access in code behind as follows
string strServerAddress = ConfigurationManager.AppSettings["ServerAdd"].toString();
string strPort = ConfigurationManager.AppSettings["Port"].toString();
mark as answer if solves your problem.
< small>< big>< pre>< pre lang ="c#"</pre></pre> ;</big></small>
<small><big><pre><pre lang="c#"></pre></pre></big></small>