我想知道是否有任何方法来嵌入电子邮件设置 Windows应用程序,然后存储在app.confg文件中。 设置将是静态的,因此用户不必在运行时更改它 时间。据我所知,我们可以将它保存在资源文件中,字符串为 ,但我如何访问我的代码中的设置?在windows应用程序中嵌入电子邮件设置
代码:
string st = Properties.Resources.cubemail;
//SmtpSection smtpSection = ConfigurationManager.GetSection(st) as SmtpSection;
MailSettingsSectionGroup mMailSettings =
ConfigurationManager.GetSection(st) as MailSettingsSectionGroup;
mail.From = new MailAddress(mMailSettings.Smtp.From);
smtp.Host = mMailSettings.Smtp.Network.Host;
smtp.Port = mMailSettings.Smtp.Network.Port;
smtp.UseDefaultCredentials = mMailSettings.Smtp.Network.DefaultCredentials;
smtp.Credentials = new System.Net.NetworkCredential(
mMailSettings.Smtp.Network.UserName,
mMailSettings.Smtp.Network.Password);
但它是可见的,当它会包分配? – Aaraadhana 2011-12-29 05:41:31
nope,它将不可见 – 2011-12-29 05:44:23
感谢您的帮助 – Aaraadhana 2011-12-29 05:46:09