发送电子邮件

来源:互联网 发布:汉密尔顿学院 知乎 编辑:程序博客网 时间:2024/06/10 20:10

MailMessage myMail = new MailMessage();
            myMail.From = "";//发邮件人的邮箱
            SmtpMail.SmtpServer = "smtp.163.com";
            myMail.Fields.Add(" http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication
            myMail.Fields.Add(" http://schemas.microsoft.com/cdo/configuration/sendusername", "发件人邮箱"); //发邮件人的邮箱
            myMail.Fields.Add(" http://schemas.microsoft.com/cdo/configuration/sendpassword", "发件人邮箱密码"); //发邮件人的邮箱密码
            myMail.To = "收件人邮箱";//接受邮件人的邮箱
            myMail.Subject = "邮件标题!";//邮件标题
            myMail.Body = "邮箱内容!";//邮箱内容
            SmtpMail.Send(myMail);//确定发送
            Response.Write("ok!");

原创粉丝点击