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

java - How to pass parameters between Request-Scoped Controllers? -

actionscript 3 - Flex: moving a point with rotation doesnt change the point XY? -

ms access - C# - Using OleDbParameter on table name -