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

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

2.

   else if (e.CommandName == "ConnectTest")
{
string sSERVER_URL = new DynamicControl(this, "SERVER_URL").Text;
string sPORT = new DynamicControl(this, "PORT").Text;
string sEMAIL_USER = new DynamicControl(this, "EMAIL_USER").Text;
Guid gINBOUND_EMAIL_KEY = Sql.ToGuid(Application["CONFIG.InboundEmailKey"]);
Guid gINBOUND_EMAIL_IV = Sql.ToGuid(Application["CONFIG.InboundEmailIV"]);
string sEMAIL_PASSWORD = Sql.ToString(ViewState["smtppass"]);
if (!Sql.IsEmptyString(sEMAIL_PASSWORD))
sEMAIL_PASSWORD = Security.DecryptPassword(sEMAIL_PASSWORD, gINBOUND_EMAIL_KEY, gINBOUND_EMAIL_IV);
ReceiveEmailByOpenPop(sEMAIL_USER, sEMAIL_PASSWORD);
}
else if (e.CommandName == "ReceiveTest")
{
Guid gINBOUND_EMAIL_KEY = Sql.ToGuid(Application["CONFIG.InboundEmailKey"]);
Guid gINBOUND_EMAIL_IV = Sql.ToGuid(Application["CONFIG.InboundEmailIV"]);
string sEMAIL_PASSWORD = Sql.ToString(ViewState["smtppass"]);
if (!Sql.IsEmptyString(sEMAIL_PASSWORD))
sEMAIL_PASSWORD = Security.DecryptPassword(sEMAIL_PASSWORD, gINBOUND_EMAIL_KEY, gINBOUND_EMAIL_IV); string sSERVICE = new DynamicControl(this, "SERVICE").SelectedValue;
string sSERVER_URL = new DynamicControl(this, "SERVER_URL").Text;
int nPORT = new DynamicControl(this, "PORT").IntegerValue;
bool bMAILBOX_SSL = new DynamicControl(this, "MAILBOX_SSL").Checked;
string sEMAIL_USER = new DynamicControl(this, "EMAIL_USER").Text;
string sMAILBOX = new DynamicControl(this, "MAILBOX").Text;
StringBuilder sbErrors = new StringBuilder();
if (String.Compare(sSERVICE, "pop3", true) == )
{
PopUtils.Validate(Context, sSERVER_URL, nPORT, bMAILBOX_SSL, sEMAIL_USER, sEMAIL_PASSWORD, sbErrors);
ctlDynamicButtons.ErrorText = sbErrors.ToString();
}
else if (String.Compare(sSERVICE, "imap", true) == )
{
ImapUtils.Validate(Context, sSERVER_URL, nPORT, bMAILBOX_SSL, sEMAIL_USER, sEMAIL_PASSWORD, sMAILBOX, sbErrors);
ctlDynamicButtons.ErrorText = sbErrors.ToString();
}
else
{
throw (new Exception("Unknown/unsupported mail service: " + sSERVICE));
}
}
上一篇:用Wireshark抓包分析超过70秒的请求


下一篇:重新组织 vs 重新生成索引