Mail Settings in Web.config

Can I set the "to" attribute in the mailSettings element in the Web.config file?

+6
source share
4 answers

You can add Key

  <appSettings> <add key="EmailToAddress" value=" 1337@gmail.com "/> </appSettings> 

And from your code you can get it like this:

 var toAddress= ConfigurationManager.AppSettings["EmailToAddress"]; 
+5
source share

No that's not

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

Set the default value to "in" AppSetting and use it from the mail sending logic.

This is an example taken from msdn docs:

 <mailSettings> <smtp deliveryMethod="network" from=" ben@contoso.com "> <network host="localhost" port="25" defaultCredentials="true" /> </smtp> </mailSettings> 
+7
source share

No, you can indicate where mail from comes from :

MSDN Link

0
source share

No, no, but that would be extremely restrictive, as you would probably want to send emails to many other people, perhaps based on some other data.

If you only send to the same address all the time (for example, an administrator account), I recommend that you simply put the address in web.config as the "appSetting" key and read it instead.

0
source share

All Articles