发送邮件

/// <summary>
/// 发送邮件
/// </summary>
/// <param name="SendTo">发送人的地址</param>
/// <param name="MyEmail">我的Email地址</param>
/// <param name="SendTitle">发送标题</param>
/// <param name="SendBody">发送的内容</param>
/// <param name="SendShowName">我的Email登录名</param>
/// <param name="MyEmailPassWord">我的Email密码</param>
/// <param name="MyEmailSmtp">Smtp邮件服务器</param>
/// <param name="FilePath">附件地址</param>
private void SendEmail(string SendTo, string MyEmail, string SendTitle, string SendBody, string SendShowName, string MyEmailPassWord,string FilePath, string MyEmailSmtp)
{


MailMessage mailObj = new MailMessage();
mailObj.From = new MailAddress(MyEmail);//"发送邮箱地址"
mailObj.To.Add(SendTo);//"接收邮箱地址"
mailObj.Subject = SendTitle;// "主题"
mailObj.Body = SendBody;// "内容"
mailObj.Attachments.Add(new Attachment(FilePath));
mailObj.IsBodyHtml = true;

SmtpClient smtp = new SmtpClient();
smtp.Host = MyEmailSmtp;// "邮件服务器地址"

smtp.UseDefaultCredentials = true;
smtp.Credentials = new NetworkCredential(SendShowName, MyEmailPassWord);//"登录用户名","登录密码"

smtp.Send(mailObj);
MessageBox.Show("发送成功");

}

你可能感兴趣的:(发送邮件)