欢迎访问!
您的支持是我们不断前行的动力!

C# 发送邮件,发送Email

C# 发送邮件,发送Email,此处以QQ邮箱为例

using System.Text;
using System.Net.Mail;

/// <summary>
/// 发送邮件
/// </summary>
/// <param name="emailFrom">发件人</param>
/// <param name="emailTo">收件人</param>
/// <param name="title">标题</param>
/// <param name="body">正文</param>
/// <param name="password">密码或授权码</param>
internal static void SendEmail(string emailFrom, string emailTo, string title, string body, string password)
{
    MailAddress from = new MailAddress(emailFrom);
    MailMessage message = new MailMessage() { Body = body, IsBodyHtml = true, BodyEncoding = Encoding.UTF8, Subject = title, SubjectEncoding = Encoding.UTF8, From = from, Priority = MailPriority.High };
    message.To.Add(emailTo);
    SmtpClient client = new SmtpClient() { EnableSsl = true, Host = "smtp.qq.com", Port = 587, };
    client.Credentials = new System.Net.NetworkCredential(emailFrom, password);
    try
    {
        client.Send(message);
    }
    catch { }
}
赞(0) 打赏
转载请注明出处,未注明出处不得转载,蜘蛛侠 » C# 发送邮件,发送Email
分享到: 更多 (0)

评论 抢沙发

评论前必须登录!

 

蜘蛛侠,您身边的爬虫专家!

觉得文章有用就打赏一下文章作者吧

支付宝扫一扫打赏

微信扫一扫打赏