I've put mail settings in app.config and can successfully pull them into a mailSettingsSectionGroup object. However, I'm not sure how to send a message using these settings.
This is what I have so far:
System.Configuration.Configuration config =
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
MailSettingsSectionGroup mailSettings =
config.GetSectionGroup("system.net/mailSettings") as
System.Net.Configuration.MailSettingsSectionGroup;
What do I need to do next to use the mailSettings object?
System.Net.Mail.SmtpClient
Specifically, the
Send(...)
method.SmtpClient
will automatically pull the details from your app/web.config file. You don't need to do anything to use the configuration, it's all handled automatically.Edit to add SMTP
Web.Config
Example: