Tuesday, March 13, 2012

SmtpMail.SmtpServer

Hi!

I want to use SmtpMail to sent mail, I user this thing in a lot o function alogn my aplication, in web.config I have this
<system.net>
<!--Setari de Email (SMTP SERVER);-->
<mailSettings>
<smtp from="admin@dotnet.itags.org.powertracker.us">
<network host="localhost" password="" userName=""/>
</smtp>
</mailSettings>
</system.net>

How can I use this to save SmtpMail.SmtpServer , because if I want to change my smtpserver i don`t want to change a lot of code!

With regards,
Sebastian TecsiThere is probably a better way in 2.0, but I've always done the following:

Web.config:

<appSettings>
<add key="SmtpServer" value="mail.ecc-solutions.com" />
</appSettings
Code:

SmptMail.SmtpServer = ConfigurationSettings.AppSettings.Item("SmtpServer")

Now all you have to do is change the SmtpServer once in the web.config file.

0 comments:

Post a Comment