惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Hacker News: Ask HN
Hacker News: Ask HN
H
Help Net Security
Microsoft Azure Blog
Microsoft Azure Blog
B
Blog RSS Feed
Jina AI
Jina AI
Stack Overflow Blog
Stack Overflow Blog
量子位
博客园_首页
Vercel News
Vercel News
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Forbes - Security
Forbes - Security
IT之家
IT之家
N
News and Events Feed by Topic
S
Security Affairs
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Webroot Blog
Webroot Blog
Recorded Future
Recorded Future
L
LangChain Blog
Y
Y Combinator Blog
AI
AI
MyScale Blog
MyScale Blog
大猫的无限游戏
大猫的无限游戏
小众软件
小众软件
Know Your Adversary
Know Your Adversary
AWS News Blog
AWS News Blog
Help Net Security
Help Net Security
Cyberwarzone
Cyberwarzone
L
Lohrmann on Cybersecurity
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Google Online Security Blog
Google Online Security Blog
V2EX - 技术
V2EX - 技术
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
PCI Perspectives
PCI Perspectives
I
Intezer
T
Tenable Blog
G
Google Developers Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
T
Troy Hunt's Blog
L
LINUX DO - 最新话题
云风的 BLOG
云风的 BLOG
C
CXSECURITY Database RSS Feed - CXSecurity.com
有赞技术团队
有赞技术团队
O
OpenAI News
P
Proofpoint News Feed
TaoSecurity Blog
TaoSecurity Blog
C
Check Point Blog
Last Week in AI
Last Week in AI
S
Schneier on Security
Simon Willison's Weblog
Simon Willison's Weblog
Blog — PlanetScale
Blog — PlanetScale

博客园 - zhangbaoyu

Asp.net项目因Session阻塞导致页面打开速度变慢 jquery.chosen.js实现模糊搜索 SQL Server 使用日志传送 SQL Server 2008 R2 主从数据库同步 JavaScript及C# URI编码详解 sql server日期时间函数 MySQL十大优化技巧 - zhangbaoyu - 博客园 第一季 开封菜。。。。 Eval( " ")和DataBinder.Eval(Container.DataItem, " ") Navicat 一学生问英语老师“山寨”的英语怎么说,老师沉默不语。过了一会儿,幽幽的转过头来,一顿一顿的说道:made in china... MySQL DATE_FORMAT() 函数 js日期时间格式验证,时间比较 笔记本显卡排名 如何使用URL跳转解决Web服务80端口被封问题? vb.net sqlserver 寒山诗选 c# 写入文件日志 - zhangbaoyu - 博客园
c# smtp发送邮件
zhangbaoyu · 2010-03-24 · via 博客园 - zhangbaoyu

2010-03-24 08:45  zhangbaoyu  阅读(371)  评论()    收藏  举报

public static string SendSMTPEMail(Model.ModelMail_Management modelmail)
{
    System.Net.Mail.MailAddress from = new System.Net.Mail.MailAddress(modelmail.MailSenderFrom, modelmail.MailSenderFrom);

    System.Net.Mail.MailAddress to = new System.Net.Mail.MailAddress(modelmail.MailSenderTo, modelmail.MailSenderTo);

    System.Net.Mail.MailMessage oMail = new System.Net.Mail.MailMessage(from, to);

    oMail.Subject = modelmail.MailSubject;
    oMail.Body = modelmail.MailBody;

    oMail.IsBodyHtml = true;
    oMail.BodyEncoding = System.Text.Encoding.UTF8;

    //Attachment attachFile = new Attachment("d:\\myinfo.rar");
    //oMail.Attachments.Add(attachFile);

    oMail.Priority = System.Net.Mail.MailPriority.Normal;

    System.Net.ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(ValidateServerCertificate);

    System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();
    client.Host = modelmail.MailSenderAddress;

    client.Port = Convert.ToInt32(modelmail.MailSenderPort);
    client.Timeout = 100000;
    client.ServicePoint.MaxIdleTime = 1;

    client.UseDefaultCredentials = false;
    client.Credentials = new System.Net.NetworkCredential(modelmail.MailSenderFrom, modelmail.MailSenderPassport);
    client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;


    try
    {
        client.Send(oMail);
        return "OK";
    }

    catch (System.Net.Mail.SmtpException ex)
    {
        return ex.Message.ToString();
    }
    finally
    {
        oMail.Dispose();
    }
}