asp.net - Accessing SMTP Mail Settings from Web.Config File by using c# -



asp.net - Accessing SMTP Mail Settings from Web.Config File by using c# -

need read smtp email settings defined under system.net section in web.config file.

below 1 illustration of smtp email setting defined in web.config file: (under section)

<system.net> <mailsettings> <smtp deliverymethod="network" from="testuser@domail.com"> <network defaultcredentials="true" host="localhost" port="25" username="user” password="testpassword"/> </smtp> </mailsettings> </system.net>

how access smtp mail service setting using c#

you can utilize webconfigurationmanager:

configuration configurationfile = webconfigurationmanager.openwebconfiguration(request.applicationpath); mailsettingssectiongroup mailsettings = configurationfile.getsectiongroup("system.net/mailsettings") mailsettingssectiongroup; response.write(mailsettings.smtp.network.host);

c# asp.net web-config

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -