I am trying to add a second email address to the web config file like this:
<add key="adminEmail" value="user1@gmail.com,user2@gmail.com"/>
it works with one email address but not two. Is it possible to add two email addresses?
thanks.
I am trying to add a second email address to the web config file like this:
<add key="adminEmail" value="user1@gmail.com,user2@gmail.com"/>
it works with one email address but not two. Is it possible to add two email addresses?
thanks.
You can handle this 2 ways…
#1, use multiple keys:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="adminEmail1" value="user1@gmail.com"/>
<add key="adminEmail2" value="user2@gmail.com"/>
<add key="adminEmail3" value="user1@gmail.com,user2@gmail.com"/>
</appSettings>
</configuration>
Or, #2. Parse the key, and separating them by delimenter, in your case the “,” character:
char[] separator = new char[] { ',' };
string connectionInfo = ConfigurationSettings.AppSettings["adminEmail3"];
string[] strSplitArr = connectionInfo.Split(separator);
foreach (string arrStr in strSplitArr)
{
//handle e-mail data here
}
Good Luck