c#发送邮件样例
2014-08-31 15:29 每天努力一点点 阅读(212) 评论(0) 编辑 收藏 举报1.通过gmail邮箱发送邮件
try { MailMessage mail = new MailMessage(); SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com"); mail.From = new MailAddress("username@gmail.com"); mail.To.Add("receiver@qq.com"); mail.Subject = "Test Mail"; mail.Body = "This is for testing SMTP mail from GMAIL"; SmtpServer.Port = 587; SmtpServer.Credentials = new System.Net.NetworkCredential("username", "password"); SmtpServer.EnableSsl = true; SmtpServer.Send(mail); MessageBox.Show("mail Send"); } catch (Exception ex) { MessageBox.Show(ex.ToString()); }