C# 调用163发送邮件

 private void sendMail2VistorSSL(Model.LeaveMsg msg)
    {
        var url = Request.Url.AbsoluteUri;
        var emailAcount = "anne@cXXX.com";
        var emailPassword =  "PenDsRXT3v";// "J17";    xia8gxh@163 "nqkqgff";//
        var reciver = msg.Email;
        var content =
            "<p>Thank you for your attention to Jack sewing machine!</p>" +
            "<p>We have received your message and we will contact with you as soon as possible!</p>" +
            "<p>Thanks again!</p>" +
            "<p>================================ you leave message =============================</p>" +
          //  "<p>" + txt_Name.Text.Trim() + ", from " + txt_Country.Text.Trim() + ".</p>" +
            "<p>Left Message \"" + txt_Msg.Text.Trim() + "\" at </p>";
		if (txt_Msg.Text.Trim().IndexOf("https") >= 0)
        {
            return;
        }	
			
			content += Request.Url.AbsoluteUri;
        System.Web.Mail.MailMessage mail= new System.Web.Mail.MailMessage();
        //设置发件人,发件人需要与设置的邮件发送服务器的邮箱一致
   
            mail.From = emailAcount;
            //设置收件人,可添加多个,添加方法与下面的一样
            mail.To = reciver;
            //设置抄送人
            mail.Cc = "xiaofei2008gxh@163.com;" + emailAcount;
            //设置邮件标题
            mail.Subject = "杰克官网访客留言信息";
            //设置邮件内容
            mail.Body = content;
            mail.BodyFormat = System.Web.Mail.MailFormat.Html;
            //message.BodyEncoding=System.Text.Encoding.GetEncoding( "gb2312 "); 
            mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //身份验证
            mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", mail.From); //邮箱登录账号,这里跟前面的发送账号一样就行
            mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", emailPassword); //这个密码要注意:如果是一般账号,要用授权码;企业账号用登录密码
            mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", 465);//端口
            mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpusessl", "true");//SSL加密
            System.Web.Mail.SmtpMail.SmtpServer = "smtp.exmail.qq.com";    //企业账号用smtp.exmail.qq.com
            System.Web.Mail.SmtpMail.Send(mail);
    }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

gavin_gxh

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值