I am building an app that needs to dynamically/programatically know of and use different SMTP settings when sending email.
I'm used to using the system.net/mailSettings approach, but as I understand it, that only allows one SMTP connection definition at a time, used by SmtpClient().
However, I need more of a connectionStrings-like approach, where I can pull a set of settings based on a key/name.
Any recommendations? I'm open to skipping the tradintional SmtpClient/mailSettings approach, and I think will have to...
I ended up building my own custom configuration loader that gets used in an EmailService class. Configuration data can be stored in web.config much like connection strings, and pulled by name dynamically.
I had the same need and the marked answer worked for me.
I made these changes in the
web.config:
Then, I have a thread that send the mail:
SomePage.cs
Thank you =)