復制代碼 代碼如下:
public static void SendEmail()
{
System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();
//這裡使用QQ的郵箱來發送測試,如果是其它郵箱,請根據其它郵箱POP3/IMAP/SMTP服務來設置
client.Host = "smtp.qq.com";
client.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential("6你的郵箱www.jb51.net", "***密碼***");
client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage("60**你的*www.jb51.net"541**收件人的www.jb51.net");
message.Subject = "主題";
message.Body = "內容";
message.BodyEncoding = System.Text.Encoding.UTF8;
message.IsBodyHtml = true;
try
{
client.Send(message);
}
catch
{
}
}