I'd like to know the best way to identify a message, using Aspose Pop3Client.
I log in with Pop3, and then i list the messages. Then, later, i log in again, and i wish to know the "new" messages. (I don't know, and I don't want to know, if some message has been deleted).
By now, for this purpouse, i'm using the "MailMessage.MessageId" property. It seems to work fine, but in this way, I have to "Fetch" EVERY message in the mailbox. The mailbox size is growing, and the things are getting sooo slow....
In your scenario, you can check Pop3MessageInfo.UniqueId Property and search in your database. If the ID is already present, that means, you have downloaded the message. Otherwise, its new and you can save it in the DB.
The problem, now is this: in the current release of my software, the property used for this pourpose is "MailMessage.MessageId". I've noticed that its value, is different from the property you talk about.
So, i cannot use it, since i've a DB full of data.... are you sure there is not a way to obtain the "MailMessage.MessageId" without opening the whole message?
You can identify the new message on Pop3 by both MailMessage.MessageID and Pop3MessageInfo.UniqueID.
If you use Pop3MessageInfo.UniqueID, it will run faster but the whole message would not be downloaded. You will just get the basic info like UniqueID, sequence number, subject etc.
If you use MailMessage.MessageID, you need to first fetch the message from Pop3 server by calling FetchMessage(int sequencenumber).
Since, you already have saved MessageID in your DB, you need to create a new field for “UniqueID” and update this field with the valid UniqueID from the Pop3 server. You can easily map the UniqueID with the MessageID.
The Pop3Client.ListMessage() returns Pop3MessageInfoCollection. Do a foreach on this collection to get the UniqueID and sequence number. You have got the sequence number. Now call FetchMessage() and give sequence number as parameter. FetchMessage() will return you object of type MailMessage. And you can get the MessageID from this object. Once you have this map saved somewhere in the DB table or in hashtable etc, you can update the existing records according to the map.
There might be some messages which are deleted from pop3 server, but they exists in the DB. For such message, you can create GUID and update the UniqueID field.
You may also find this technical tip ([http://www.aspose.com/documentation/utility-components/aspose.network-for-.net/detecting-new-email-messages-on-pop3-server.html ](http://www.aspose.com/documentation/utility-components/aspose.network-for-.net/detecting-new-email-messages-on-pop3-server.html)) useful. Sample code is given for Aspose library usage and pseudo-code for DB usage.