添加jmail引用
public static int SendMail(string toMail, string subject,string body)
{
string serverName = "";
string email = "";
string userName = "";
string password = "";
GetMailConfig(out serverName, out email, out userName, out password); // 发送邮件需要的参数,你可以自己设置
jmail.Message Jmail = new jmail.Message();
Jmail.Silent = true;
Jmail.Logging = true;
Jmail.Charset = "GB2312";
Jmail.ContentType = "text/html";
Jmail.AddRecipient(toMail, "", "");
Jmail.ReplyTo = ""; // 答复邮件地址
Jmail.From = email;
Jmail.MailServerUserName = userName;
Jmail.MailServerPassWord = password;
Jmail.Subject = subject;
Jmail.Body = body;
Jmail.Send(serverName, false);
Jmail.Close();
return Jmail.ErrorCode; // 返回 0 表示成功
}
public static int SendMail(string toMail, string subject,string body)
{
string serverName = "";
string email = "";
string userName = "";
string password = "";
GetMailConfig(out serverName, out email, out userName, out password); // 发送邮件需要的参数,你可以自己设置
jmail.Message Jmail = new jmail.Message();
Jmail.Silent = true;
Jmail.Logging = true;
Jmail.Charset = "GB2312";
Jmail.ContentType = "text/html";
Jmail.AddRecipient(toMail, "", "");
Jmail.ReplyTo = ""; // 答复邮件地址
Jmail.From = email;
Jmail.MailServerUserName = userName;
Jmail.MailServerPassWord = password;
Jmail.Subject = subject;
Jmail.Body = body;
Jmail.Send(serverName, false);
Jmail.Close();
return Jmail.ErrorCode; // 返回 0 表示成功
}