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

推荐订阅源

F
Fortinet All Blogs
Microsoft Security Blog
Microsoft Security Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Vercel News
Vercel News
Application and Cybersecurity Blog
Application and Cybersecurity Blog
C
Check Point Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
W
WeLiveSecurity
The Hacker News
The Hacker News
L
LINUX DO - 热门话题
T
Tenable Blog
Hugging Face - Blog
Hugging Face - Blog
Google Online Security Blog
Google Online Security Blog
博客园 - Franky
P
Proofpoint News Feed
H
Hacker News: Front Page
P
Privacy & Cybersecurity Law Blog
月光博客
月光博客
P
Proofpoint News Feed
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
The GitHub Blog
The GitHub Blog
云风的 BLOG
云风的 BLOG
博客园_首页
www.infosecurity-magazine.com
www.infosecurity-magazine.com
C
CERT Recently Published Vulnerability Notes
Forbes - Security
Forbes - Security
I
InfoQ
Stack Overflow Blog
Stack Overflow Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Attack and Defense Labs
Attack and Defense Labs
N
News and Events Feed by Topic
博客园 - 叶小钗
T
Threat Research - Cisco Blogs
aimingoo的专栏
aimingoo的专栏
D
Darknet – Hacking Tools, Hacker News & Cyber Security
小众软件
小众软件
大猫的无限游戏
大猫的无限游戏
MongoDB | Blog
MongoDB | Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Hacker News - Newest:
Hacker News - Newest: "LLM"
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 司徒正美
O
OpenAI News
G
Google Developers Blog
Martin Fowler
Martin Fowler
罗磊的独立博客
S
SegmentFault 最新的问题
T
Tor Project blog
量子位

博客园 - 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();
    }
}