Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to include an email address "display name" in the smtp element of a Web.config file? [duplicate]

Possible Duplicate:
Storing Smtp from email friendly display name in Web.Config

I'm working on an EmailSender, 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.

In my Web.config file, I have included a default "from email address", like this:

<configuration>
  <system.net>
    <mailSettings>
      <smtp from="[email protected]"><!-- no displayName attribute :( -->
        <network ... />
      </smtp>
    </mailSettings>
  </system.net>
</configuration>

In my EmailSender, I have something like this:

        var smtpSection = ...;
        var message = new MailMessage();
        message.From =  new MailAddress(_settings.From, senderDisplayName);

Is there a recommended way to store senderDisplayName in a web.config file?

  • Is there some way to include it in the from attribute? For example:

    <smtp from="Automatic Mailer &lt;[email protected]&gt;">
    
  • Or does it need to be a custom element in appSettings?
  • Or is there some other way?
like image 373
devuxer Avatar asked Feb 01 '10 22:02

devuxer


1 Answers

Here check this thread, might be of help:

Storing Smtp from email friendly display name in Web.Config

like image 168
Albert Avatar answered Sep 24 '22 20:09

Albert