标签:
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