Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mail settings in Web.config

Tags:

asp.net

Is it possible to set a "to" attribute in the mailSettings element in the Web.config file?

like image 766
Anjana Avatar asked Mar 04 '11 11:03

Anjana


2 Answers

No, it isn't

Here is the docs for mailSettings: http://msdn.microsoft.com/en-us/library/w355a94k.aspx

Set the default "to" in an AppSetting instead and use that from you mail sending logic.

This is an example taken from the msdn docs:

<mailSettings>
  <smtp deliveryMethod="network" from="[email protected]">
    <network
      host="localhost"
      port="25"
      defaultCredentials="true"
    />
  </smtp>
</mailSettings>
like image 135
Mikael Östberg Avatar answered Oct 31 '22 11:10

Mikael Östberg


You can add a Key

   <appSettings>
    <add key="EmailToAddress" value="[email protected]"/> 

</appSettings>

And from your codebehind you can get it like this

var toAddress= ConfigurationManager.AppSettings["EmailToAddress"];
like image 26
Kimtho6 Avatar answered Oct 31 '22 11:10

Kimtho6