使用OpenPop库阅读电子邮件.邮件ID出现问题. [英] Reading emails using OpenPop library. Problem with Message-ID.
问题描述
因此,我需要使用POP3阅读来自电子邮件服务器(公共,免费,网络提供商)的所有电子邮件.我使用OpenPop库(我做了一些研究,但仍然不确定该选择).
收到的电子邮件,我想保存到数据库中.要确定是否电子邮件已经在数据库中,我想使用消息ID(将其保存在单独的列中).这是我收件箱中每封电子邮件的uniq值,对不对?
但是,问题出在哪里:
我几乎没有收到任何电子邮件.有问题的电子邮件(消息ID为空)来自CodeProject通讯和我本人(我从C#代码发送了一些电子邮件进行测试).这些电子邮件的messageID == null.
那怎么可能,有人可以向我解释吗?
这是我的测试代码:
Hi,
so, I need to read all emails from email server (public, free, web provider), with POP3. I use OpenPop library (I do some research, and still not sure about that choice).
Received emails I want to save in my database. To identify, whether email already is in database i want to use message-ID (save it in separate column). It is uniq value for every email in my inbox, right?
But, what the problem:
I received almost all emails with no problem. Emails with problem (with null message-ID) were from CodeProject newsletter and from myself (I send some emails from C# code for test). Those emails were received with messageID == null.
How is that possible, can anybody explain me?
Here is my test code:
pop3Client = new Pop3Client();
if (pop3Client.Connected)
pop3Client.Disconnect();
pop3Client.Connect("poczta.o2.pl", 995, true);
pop3Client.Authenticate("mnd017@com", "231231");
int count = pop3Client.GetMessageCount();
for (int i = count; i >= 1; i -= 1)
{
// Check if the form is closed while we are working. If so, abort
if (IsDisposed)
return;
// Refresh the form while fetching emails
// This will fix the "Application is not responding" problem
Application.DoEvents();
Message message = pop3Client.GetMessage(i);
try
{
// Here I try to read that: message.Headers.MessageId.ToString() - but MessageId is null :/
}
catch (Exception e)
{
fail++;
}
}
推荐答案
将邮件留在服务器上的客户端通常使用UIDL命令来获取消息编号与由其唯一标识符标识的消息的当前关联.唯一标识符为 任意 ,如果邮箱包含相同的消息,则可以重复该唯一标识符. (请参见 http://en.wikipedia.org/wiki/Post_Office_Protocol [
Clients that leave mail on servers generally use the UIDL command to get the current association of message-numbers to message identified by its unique identifier. The unique identifier is arbitrary, and might be repeated if the mailbox contains identical messages. (see http://en.wikipedia.org/wiki/Post_Office_Protocol[^] )
So no messageID is possible.
这篇关于使用OpenPop库阅读电子邮件.邮件ID出现问题.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!