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);
}
unity 发送邮件
点赞
收藏