110,533
社区成员
发帖
与我相关
我的任务
分享
ReadPop3 a = new ReadPop3();
List<OpenPop.Mime.Message> L = new List<OpenPop.Mime.Message>();
L = ReadPop3.FetchAllMessages(textBox1.Text,995, true, textBox2.Text, textBox3.Text);
MessageBox.Show(L.Count.ToString());
public static List<OpenPop.Mime.Message> FetchAllMessages(string hostname, int port, bool useSsl, string username, string password)
{
// The client disconnects from the server when being disposed
using (Pop3Client client = new Pop3Client())
{
if (useSsl)
{
client.Connect(hostname, port, true, 10000, 10000, certificateValidator);
}
else
{
client.Connect(hostname, port, useSsl);
}
client.Authenticate(username, password);
int messageCount = client.GetMessageCount();
List<OpenPop.Mime.Message> allMessages = new List<OpenPop.Mime.Message>(messageCount);
for (int i = messageCount; i > 0; i--)
{
allMessages.Add(client.GetMessage(i));
}
return allMessages;
}
}
private static bool certificateValidator(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslpolicyerrors)
{
return true;
}