.NET Mail Setting

来源:互联网 发布:vslam 算法 编辑:程序博客网 时间:2024/05/13 13:51
首先需要在Web.config中设置这些信息:
  <system.net>    <mailSettings>      <smtp deliveryMethod="Network" from="BTS@hengtiansoft.com">        <network host="mail.hengtiansoft.com" port="587" userName="BTS" password="password"/>      </smtp>    </mailSettings>  </system.net>

然后在调用的.cs文件中:

        static Configuration config = WebConfigurationManager.OpenWebConfiguration("~/");        static MailSettingsSectionGroup settings = (MailSettingsSectionGroup)config.GetSectionGroup("system.net/mailSettings");        private static string systemID = settings.Smtp.Network.UserName;        private static string systemPassword = settings.Smtp.Network.Password;        private static string SMTPHost = settings.Smtp.Network.Host;        private static int SMTPPort = settings.Smtp.Network.Port;

记得添加一些必要的引用。

0 0
原创粉丝点击