用gmail发送邮件

if (Page.IsValid)
        {
            MembershipUser user = Membership.GetUser(textboxId.Text.Trim());
            if (user == null)
            {
                labelMessage.Text = "此帐号不存在!";
            }
            else
            {
                string email = user.Email;
                if (email == textboxPass.Text.Trim())
                {
                    user.UnlockUser();
                    string newPass = user.ResetPassword();
                    if (newPass != null)
                    {
                        MailMessage mail = new MailMessage();
                        mail.To = textboxPass.Text.Trim();
                        mail.From = "pwqzc1688@gmail.com";
                        mail.Subject = "99收藏夹--找回密码";
                        mail.BodyFormat = MailFormat.Html;
                        //mailMsg.Priority = MailPriority.High;
                        mail.Body = "尊敬的"+textboxId.Text.Trim()+":<br/>您好!<br/>您在99收藏夹的密码已经被更新为:<span style='color:red;'>"+newPass+"</span><br/>请您登陆后更改密码,谢谢";
                        mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication
                        mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "pwqzc1688"); //set your username here
                        mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "你的密码"); //set your password here
                        mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", "465");
                        mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpusessl", "1");
                        SmtpMail.SmtpServer = "smtp.gmail.com"; //your real server goes here
                        SmtpMail.Send(mail);


                        labelMessage.Text = "找回密码成功,密码已经成功的发送到您的邮箱,请查收!";
                    }
                    else
                    {
                        labelMessage.Text = "您的输入正确,但是找回密码失败,请再单击找回密码按钮!";
                    }
                }
                else
                {
                    labelMessage.Text = "找回密码失败,帐号和Email不吻合!";
                }
            }

转载于:https://www.cnblogs.com/pwqzc/archive/2006/06/12/423651.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值