Click here to Skip to main content
15,894,896 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Is there a way to get the value on the dropdown list to send email that was selected on the dropdown list using appsetting?

Im done sending email that was on the web.config.
Here's my example to send email using the appsetting that was already on the web.config
HTML
<pre><add key="EmailSender" value="Sender@gmail.com"/>

HTML
<pre><add key="EmailReceiver" value="Receiver@gmail.com"/>

HTML
<pre><add key="EmailReceiver2" value="Receiver2@gmail.com"/>


What I have tried:

And now i want to get the email address that was on the dropdown list from the other page to send email and here's the dropdownlist.
ASP.NET
<pre><asp:DropDownList runat="server" ID="ddlEmail" Height="30px" Width="270px">
                    <asp:ListItem Selected="True">-- Select Email --</asp:ListItem>
                    <asp:ListItem>Sample@gmail.com</asp:ListItem> //Sample Email
                    <asp:ListItem>Sample1@gmail.com</asp:ListItem> //Sample Email
                    <asp:ListItem>Sample2@gmail.com</asp:ListItem> //Sample Email
                    <asp:ListItem>Sample3@gmail.com</asp:ListItem> //Sample Email
                    <asp:ListItem>Sample4@gmail.com</asp:ListItem> //Sample Email
                    <asp:ListItem>Sample5@gmail.com</asp:ListItem> //Sample Email
                    </asp:DropDownList>


and i have a class to get the value of the email.
email.From = new MailAddress(ConfigurationManager.AppSettings["EmailSender"]);


guys can you help me to get the value that was on the dropdown list using the appsetting? Thanks in advance
Posted
Updated 29-Oct-17 3:42am
v2
Comments
Kornfeld Eliyahu Peter 29-Oct-17 10:07am    
How actually AppSettings connected to your DropDownList?
Member 13427032 29-Oct-17 11:38am    
i did not set-up yet the connection on the dropdownlist. i try on the appsetting
<add key="ReopenReceiver" value="Sample@gmail.com"/>
<add key="ReopenReceiver" value="Sample2@gmail.com"/> and it get only the Sample2@gmail.com but i selected the first one
P_Z 29-Oct-17 11:38am    
You can create a key value list using the Config values and bind list with dropdown.

Also why are emails stored stored in the Config? In this case it may be better to store emails in a database since if you change config, server pool would auto restart.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900