views:

686

answers:

2

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?

A: 

Here is a simple example.

GrayWizardx
Oh god that example uses hungarian, and on microsofts own site, tut tut, it also doesn't answer the question.
Paul Creasey
He asked for how to send mail, that does it. All you need to do is transfer the properties in the config section to the appropriate parts of that example. MailSettings is only the settings for the mail transport, it really has nothing to do with actually sending the email.
GrayWizardx
+2  A: 

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.

DaRKoN_