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 <[email protected]>">
appSettings
?Here check this thread, might be of help:
Storing Smtp from email friendly display name in Web.Config
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With