【发布时间】:2018-05-24 13:18:31
【问题描述】:
我正在尝试连接到 pop3 帐户并获取包含所有标题的所有电子邮件。我使用 mailkit 在 C# 中执行此任务。 问题是我搜索了如何在一个字符串中获取所有标题的示例,但我没有找到这样做的方法。
using (var client = new Pop3Client())
{
try
{
client.ServerCertificateValidationCallback = (s, c, h, e) => true;
client.Connect("pop3.host.com", 110, false);
client.AuthenticationMechanisms.Remove("XOAUTH2");
client.Authenticate("mail@host.com", "password");
for (int i = 0; i < client.Count; i++)
{
// below I have the problem. I dont know how request the complete headers of a message/mail
header = client.getGetMessageHeaders(i).ToArray;
Console.WriteLine("..." + header);
}
client.Disconnect(true);
}
catch (Exception ex)
{
Console.WriteLine("Checking error: \n\n" + ex.Message + "\n\n\n");
}
}
如您所见,我尝试在数组中获取标题,以便在使用此数组为字符串提供标题后,但无法使用此代码。我是 C# 新手,我在这里请求一些帮助。
非常感谢!
【问题讨论】: