【发布时间】:2015-06-15 04:24:57
【问题描述】:
使用 POP3 我想从 Outlook 下载邮件,但我无法连接服务器。它在连接到服务器时显示。 错误是:
在 OpenPop.Pop3.Pop3Client.Connect 上找不到服务器(字符串 主机名、Int32 端口、布尔值 useSsl、Int32 接收超时、Int32 sendTimeout, RemoteCertificateValidationCallback certificateValidator) 在 Aceo.Activities.EmailPOP.RequestEmailPOP.Execute(CodeActivityContext 上下文)
在参数中,我通过:
Host number="mail.xxx.com"
Use SSl=false or true
Port Number= 110 or 995
我的代码是:
public sealed class RequestEmailPOP:CodeActivity
{
public InArgument<string> Host { get; set; }
public InArgument<string> PortNumber { get; set; }
public InArgument<string> UseSSL { get; set; }
public InArgument<string> UserName { get; set; }
public InArgument<string> Password { get; set; }
public InArgument<string> LoggedInUser { get; set; }
protected override void Execute(CodeActivityContext context)
{
string Host = context.GetValue(this.Host);
int PortNumber =Convert.ToInt32(context.GetValue(this.PortNumber));
bool UseSSL = Convert.ToBoolean(context.GetValue(this.UseSSL));
string UserName = context.GetValue(this.UserName);
string LoggedInUser = context.GetValue(this.LoggedInUser);
string Password = context.GetValue(this.Password);
using (Pop3Client client = new Pop3Client())
{
client.Connect(Host, PortNumber, UseSSL, 600, 600, CertificateValidationCallBack);
client.Authenticate(UserName, Password);
int messageCount = client.GetMessageCount();
List<string> uids = client.GetMessageUids();
List<Message> newMessages = new List<Message>();
for (int i = 0; i < uids.Count; i++)
{
string currentUidOnServer = uids[i];
if (!seenUids.Contains(currentUidOnServer))
{
Message unseenMessage = client.GetMessage(i + 1);
newMessages.Add(unseenMessage);
}
}
}
return newMessage;
}
private static bool CertificateValidationCallBack(
object sender,
System.Security.Cryptography.X509Certificates.X509Certificate certificate,
System.Security.Cryptography.X509Certificates.X509Chain chain,
System.Net.Security.SslPolicyErrors sslPolicyErrors)
{
return true;
}
如何解决此错误?
【问题讨论】:
标签: c# asp.net-mvc ssl pop3