#region 发送邮件方法
/// <summary>
/// 发送邮件方法
/// </summary>
/// <param name="bodye">发送内容</param>
/// <param name="goemail">接受邮箱</param>
public static void sendJob(string bodye, string goemail)
{
string result = bodye;
MailMessage objMailMessage;
//创建邮件消息
objMailMessage = new MailMessage();
//发送地址
objMailMessage.From = "linyizhonglinyizho@163.com";
//接收地址
objMailMessage.To = goemail;
//设置邮件正文内容的类型,这里因为是需要在内容中写条超连接,所以需要html格式
//基本权限
objMailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
//用户名
objMailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "蔺宜忠");
//密码
objMailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "linyizhong");
objMailMessage.BodyFormat = MailFormat.Html;
//邮件主题
objMailMessage.Subject = "中国千家林业网注册信息邮件!【系统邮件可勿回复】";
//邮件内容
objMailMessage.Body = result;
//服务器端的ip,因为我们用的是本地的虚拟smtp服务器,所以只需要填写本地ip地址
SmtpMail.SmtpServer = "smtp.qq.com";
//发送
SmtpMail.Send(objMailMessage);
}
/// <summary>
/// 自动发送邮件方法 仅限163的邮箱,别忘添加using System.Web.Mail;
/// </summary>
/// <param name="sendEmai">发送者邮箱</param>
/// <param name="acceptEmail">接受者邮箱</param>
/// <param name="sendPwd">发送者密码</param>
/// <param name="sendTitle">发送标题</param>
/// <param name="sendBody">发送的内容</param>
protected void SendMail(string sendEmai, string acceptEmail, string sendPwd, string sendTitle, string sendBody)
{
MailMessage mail = new MailMessage();
mail.To = acceptEmail; //接受人的邮箱
mail.From = sendEmai; //你自己的邮箱(注意qq邮箱不行)
mail.Subject = sendTitle; //邮箱标题
mail.Body = sendBody;
mail.BodyFormat = MailFormat.Html;//*******注意******蔺宜忠自己添加,表示已html形式发送********注意*******
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing", "2");
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //stmp验证
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", sendEmai.Substring(0, sendEmai.IndexOf('@')));
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", sendPwd);
SmtpMail.SmtpServer = "smtp.163.com"; //代理邮件服务器
SmtpMail.Send(mail);
}
#endregion