unity 发送邮件

 public void SendEmail()
    {
        //MailMessage mail = new MailMessage();

        //mail.From = new MailAddress("1311845207@qq.com");
        //mail.To.Add("1311845207@qq.com");
        //mail.Subject = "Test Mail";
        //mail.Body = "This is for testing SMTP mail from GMAIL";
        //mail.Attachments.Add(new Attachment("02.png"));

        //SmtpClient smtpServer = new SmtpClient("smtp.qq.com");
        //smtpServer.Credentials = new System.Net.NetworkCredential("1311845207@qq.com", "131313525252LS") as ICredentialsByHost;
        //smtpServer.EnableSsl = true;
        //ServicePointManager.ServerCertificateValidationCallback =
        //    delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
        //    { return true; };

        //smtpServer.Send(mail);
        //Debug.Log("success");

        SmtpClient mailClient = new SmtpClient("smtp.qq.com");
        mailClient.EnableSsl = true;
        //Credentials登陆SMTP服务器的身份验证.
        mailClient.Credentials = new NetworkCredential("2934064674@qq.com", "nsmotmppvijodhde") as ICredentialsByHost;
        //test@qq.com发件人地址、[url=mailto:test@tom.com]test@tom.com[/url]收件人地址
        MailMessage message = new MailMessage(new MailAddress("2934064674@qq.com"), new MailAddress("1311845207@qq.com"));

        // message.Bcc.Add(new MailAddress("tst@qq.com")); //可以添加多个收件人
        message.Body = "Hello Word!";//邮件内容
        message.Subject = "this is a test2";//邮件主题
        //Attachment 附件
        Attachment att = new Attachment(@"02.png");
        message.Attachments.Add(att);//添加附件
        Console.WriteLine("Start Send Mail....");

        ServicePointManager.ServerCertificateValidationCallback =
            delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
            { return true; };
        //发送....
        mailClient.Send(message);
    }

 

转载于:https://my.oschina.net/wu0hua0guo/blog/882040

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值