我必须访问应用程序配置文件名App.config
MailSettingsSectionGroup mailSettings =App.GetSectionGroup("system.net/mailSettings") as MailSettingsSectionGroup;
if (mailSettings != null)
{
FromMail = mailSettings.Smtp.Network.UserName;
password = mailSettings.Smtp.Network.Password;
}
应用配置文件为
<system.net>
<mailSettings>
<smtp from="abc@email.com">
<network host="smtp.server.com" port="587" userName="abc@email.com" password="password" enableSsl="true" />
</smtp>
</mailSettings>
</system.net>
当我以这种方式访问时。它表明应用程序在以下上下文中不存在。请帮助。