title: Is there a way to include an email address "display name" in the smtp element of a Web.config file?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1394354/storing-smtp-from-email-friendly-display-name-in-web-config">Storing Smtp from email friendly display name in Web.Config</a>  </p>
  </blockquote>
  
  
  
  <p>I'm working on an <code>EmailSender</code>, and I'm grabbing the email address from my Web.config file. I'd like to also grab a "display name" for that email, from the same section if possible, but I'm not seeing an obvious way to do this.</p>
  
  <p>In my Web.config file, I have included a default "from email address", like this:</p>
  
  <pre><code>&lt;configuration&gt;
    &lt;system.net&gt;
      &lt;mailSettings&gt;
        &lt;smtp from="myaddress@mydomain.com"&gt;&lt;!-- no displayName attribute :( --&gt;
          &lt;network ... /&gt;
        &lt;/smtp&gt;
      &lt;/mailSettings&gt;
    &lt;/system.net&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>In my <code>EmailSender</code>, I have something like this:</p>
  
  <pre><code>        var smtpSection = ...;
          var message = new MailMessage();
          message.From =  new MailAddress(_settings.From, senderDisplayName);
  </code></pre>
  
  <p><strong>Is there a recommended way to store <code>senderDisplayName</code> in a web.config file?</strong></p>
  
  <ul>
  <li><p>Is there some way to include it in the <code>from</code> attribute? For example:</p>
  
  <pre><code>&lt;smtp from="Automatic Mailer &amp;lt;myaddress@mydomain.com&amp;gt;"&gt;
  </code></pre></li>
  <li>Or does it need to be a custom element in <code>appSettings</code>?</li>
  <li>Or is there some other way?</li>
  </ul>