码迷,mamicode.com
首页 > 数据库 > 详细

.net使用OpenPop自动收邮件,并将邮件内容存入数据库

时间:2016-05-16 12:49:25      阅读:194      评论:0      收藏:0      [点我收藏+]

标签:

1.下载OpenPop,将OpenPop添加到解决方案中。

2.

 1   else if (e.CommandName == "ConnectTest")
 2                 {
 3                     string sSERVER_URL = new DynamicControl(this, "SERVER_URL").Text;
 4                     string sPORT = new DynamicControl(this, "PORT").Text;
 5                     string sEMAIL_USER = new DynamicControl(this, "EMAIL_USER").Text;
 6                     Guid gINBOUND_EMAIL_KEY = Sql.ToGuid(Application["CONFIG.InboundEmailKey"]);
 7                     Guid gINBOUND_EMAIL_IV = Sql.ToGuid(Application["CONFIG.InboundEmailIV"]);
 8                     string sEMAIL_PASSWORD = Sql.ToString(ViewState["smtppass"]);
 9                     if (!Sql.IsEmptyString(sEMAIL_PASSWORD))
10                         sEMAIL_PASSWORD = Security.DecryptPassword(sEMAIL_PASSWORD, gINBOUND_EMAIL_KEY, gINBOUND_EMAIL_IV);
11                     ReceiveEmailByOpenPop(sEMAIL_USER, sEMAIL_PASSWORD);
12                 }
13                 else if (e.CommandName == "ReceiveTest")
14                 {
15                     Guid gINBOUND_EMAIL_KEY = Sql.ToGuid(Application["CONFIG.InboundEmailKey"]);
16                     Guid gINBOUND_EMAIL_IV = Sql.ToGuid(Application["CONFIG.InboundEmailIV"]);
17                     string sEMAIL_PASSWORD = Sql.ToString(ViewState["smtppass"]);
18                     if (!Sql.IsEmptyString(sEMAIL_PASSWORD))
19                         sEMAIL_PASSWORD = Security.DecryptPassword(sEMAIL_PASSWORD, gINBOUND_EMAIL_KEY, gINBOUND_EMAIL_IV);
20 
21                     string sSERVICE = new DynamicControl(this, "SERVICE").SelectedValue;
22                     string sSERVER_URL = new DynamicControl(this, "SERVER_URL").Text;
23                     int nPORT = new DynamicControl(this, "PORT").IntegerValue;
24                     bool bMAILBOX_SSL = new DynamicControl(this, "MAILBOX_SSL").Checked;
25                     string sEMAIL_USER = new DynamicControl(this, "EMAIL_USER").Text;
26                     string sMAILBOX = new DynamicControl(this, "MAILBOX").Text;
27                     StringBuilder sbErrors = new StringBuilder();
28                     if (String.Compare(sSERVICE, "pop3", true) == 0)
29                     {
30                         PopUtils.Validate(Context, sSERVER_URL, nPORT, bMAILBOX_SSL, sEMAIL_USER, sEMAIL_PASSWORD, sbErrors);
31                         ctlDynamicButtons.ErrorText = sbErrors.ToString();
32                     }
33                     else if (String.Compare(sSERVICE, "imap", true) == 0)
34                     {
35                         ImapUtils.Validate(Context, sSERVER_URL, nPORT, bMAILBOX_SSL, sEMAIL_USER, sEMAIL_PASSWORD, sMAILBOX, sbErrors);
36                         ctlDynamicButtons.ErrorText = sbErrors.ToString();
37                     }
38                     else
39                     {
40                         throw (new Exception("Unknown/unsupported mail service: " + sSERVICE));
41                     }
42                 }

 

.net使用OpenPop自动收邮件,并将邮件内容存入数据库

标签:

原文地址:http://www.cnblogs.com/kangjing/p/5497461.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!