我想知道是否有任何方法來嵌入電子郵件設置 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