Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9007945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:49:28+00:00 2026-06-16T01:49:28+00:00

I have a simple application that sends out status emails to some of our

  • 0

I have a simple application that sends out status emails to some of our internal users.

I use a simple application configuration file (App.config) to store email address and name information, about the intended users. Since the appSettings section only seem to support simple key/value pairs, it currently looks like this:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key="toName" value="Recipient Name" />
    <add key="toAddr" value="some@email.com" />
    <add key="toName2" value="Another Recipient Name" />
    <add key="toAddr2" value="another@email.com" />
    <add key="ccName" value="An Archive"/>
    <add key="ccAddr" value="copies@email.com"/>
    <add key="ccName2" value="Another Archive"/>
    <add key="ccAddr2" value="morecopies@email.com"/>
  </appSettings>
</configuration>

And then I add each recipient individually in the code.

Currently, this means that every time I add or remove recipients, I also need to rewrite the code to handle the new recipients and rebuild and re-deploy the application

I would like to be able to store custom configuration entries, like this maybe:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <recipients>
    <recipient recType="to" recAddr="some@email.com" recName="Recipient Name" />
    <recipient recType="to" recAddr="another@email.com" recName="Another Recipient Name" />
    <recipient recType="cc" recAddr="copies@email.com" recName="An Archive"/>
    <recipient recType="cc" recAddr="morecopies@email.com" recName="Another Archive"/>
  </recipients>
</configuration>

So I can loop through them:

MailMessage message = new MailMessage();
foreach(recipient rec in recipients)
{
  MailAddress mailAddress = new MailAddress(recipient["recAddr"],recipient["recName"]);
  if(recipient["recType"] == "cc")
    message.CC.Add(mailAddress);
  else
    message.To.Add(mailAddress);
}

How to accomplish this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T01:49:30+00:00Added an answer on June 16, 2026 at 1:49 am

    You should write a custom config section for your recipients and then include this section. With the custom section you will be also able to store the recipients config info outside the main config file and include it using the configSource attribute.

    For a start you can look here:
    http://haacked.com/archive/2007/03/11/custom-configuration-sections-in-3-easy-steps.aspx

    In short, you should:

    1. Implement your custom config section by inheriting from ConfigurationElement (for one element) and ConfigurationElementCollection (for collections, you need collection in your case and each recipient will be element of connection). Sample implementation is in answer here:
      how to have custom attribute in ConfigurationElementCollection?

    2. Define config section in main config

    3. Add your custom configuration and it could be included as separate config file

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple Desktop Facebook application that allows the user to retrieve some
I have a simple web form that sends and email out via .NET C#.
We have a console application (currently .NET) that sends out mail in bulk to
I have an application that occasionally sends out an e-mail with three attachments. One
I have a simple application that loads an unmanaged dll and passes a few
I have a simple c++ application that generates reports on the back end of
I have a simple WPF application that uses ClickOnce to handle installing. Within this
I have a simple iPhone application that is very similar to the Page Control
I have a simple Android application that uses a JAR I have built. When
I have a simple test application (C# console application) that does an HTTP GET

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.