首页 > 编程 > .NET > 正文

.net邮箱发布邮箱信息的实例

2024-07-10 12:46:25
字体:
来源:转载
供稿:网友

代码如下:
#region 发送邮箱方法
        /// <summary>
        /// 发送邮箱方法
        /// </summary>
        /// <param name="useremail">发送到的邮箱地址</param>

    /// <param name="username">姓名</param>
        /// <returns>发送成功 返回 true 否则返回 false</returns>
        public bool GetEmail(string useremail, string username)
        {
            DateTime dt = DateTime.Now;
            string gettime = dt.ToLongDateString().ToString();
            string _MailAddress = "邮箱地址";
            string _MailNickName = "xxx";
            string _MailPassword = "邮箱密码";
            string _MailSmtpHost = "smtp.163.com";
            string _MailSmtpPort = "25";
            string _To = useremail;
            string _Title = "xxxxxx";
            string _Body = "亲爱的“" + username + "”用户:<br><br>您好!";
            string strXmlFile = HttpContext.Current.Server.MapPath("/config/mail.config");
            XmlControl XmlTool = new XmlControl(strXmlFile);
            XmlTool.Update("Root/Address", _MailAddress);
            XmlTool.Update("Root/NickName", _MailNickName);
            XmlTool.Update("Root/Password", _MailPassword);
            XmlTool.Update("Root/SmtpHost", _MailSmtpHost);
            XmlTool.Update("Root/SmtpPort", _MailSmtpPort);
            XmlTool.Update("Root/ToAddress", useremail);
            XmlTool.Update("Root/UserInfo", username);
            XmlTool.Save();
            XmlTool.Dispose();
            if (GmailHelp.GmailSendMail(username, _To, _Body, _Title, _MailAddress, _MailNickName, _MailPassword, _MailSmtpHost, int.Parse(_MailSmtpPort)))

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表