We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to identify messages


i'm an Aspose.Network customer.

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....

Is there a faster way to accomplish it?




Thanks for considering Aspose.

You can use the List functions to get the mesage list without downloading all of the message to local system.

If you can provide more details of your scenarios, we will be glad to post some sample codes for yoru referencing.


well.... this is what I have to do:

- Log into a MailBox with Pop3
- List the messages
- Is there any "new" message?
- Download new messages

How can i know if a message is "new" or "old"?

When I download a message, i don't delete it. Maybe, later, someone will delete it from POP3, but i will not do it.

When I download a message, a insert a record into a DB, with all relevant data.

I don't have to download every message. I have to download only the messages matching certain criteria.

("new" messages are all the messages not dowloaded)

According to this, what field of "MailMessage" can I use to identify if a message is "downloaded" or "new"?



Hi Andrea,

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.

ok, i've got it.

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?

Is it clear, my problem?



Hi Andrea,

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.

ok, i see…
when i’ll come back from holiday, i’ll try it, and let you know about the result…

thanks a lot.