Click here to Skip to main content
15,888,301 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
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:

C#
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++;
        }
    }
Posted
Comments
Mohammed Nazer 21-Mar-13 10:50am    
Is there any alternative way to keep track unique message if message ID is NULL.

1 solution

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.
 
Share this answer
 
Comments
mnd017 16-Aug-11 17:04pm    
So, how should I save those emails in DB? I mean, is there any uniq id attached to the messages ?
Herman<T>.Instance 17-Aug-11 1:11am    
no unique id except subject, perhaps you could add a Guid()

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900