Hi,
I am using Aspose.Email 3.9.0 and tryign to fetch and delete newly arriving messages from a Gmail account. I use asynchronous versions of all methods. This is my example code (credentials taken out):
private static Pop3Client pop3 = new Pop3Client(“[pop.gmail.com](http://pop.gmail.com/)”, 995, @“xxxx@gmail.com”, “xxxx”);
private static Timer scanTimer;
public static void Main()
{
pop3.EnableSsl = true;
scanTimer = new Timer(Pop3Async, null, 0, -1);
Console.Read();
}
static async void Pop3Async(Object o)
{
scanTimer.Change(Timeout.Infinite, Timeout.Infinite);
pop3.CommitDeletes(); //as otherwise it doesn’t even recognize new messages
Console.WriteLine(“async starting, message count: {0}”, pop3.GetMessageCount());
var messages = await Task.Factory.FromAsync(pop3.BeginListMessages(), pop3.EndListMessages);
foreach (var messageInfo in messages)
{
Console.WriteLine(“fetching message with UniqueId {0}”, messageInfo.UniqueId);
var message = await Task.Factory.FromAsync(pop3.BeginFetchMessage(messageInfo.UniqueId), pop3.EndFetchMessage);
Console.WriteLine(“message with subject {0} fetched, deleting”, message.Subject);
await Task.Factory.FromAsync(pop3.BeginDeleteMessage(messageInfo.UniqueId), pop3.EndDeleteMessage);
}
if (messages.Count > 0)
pop3.CommitDeletes();
Console.WriteLine(“async all done!”);
scanTimer.Change(1000, 1000);
}
If I run it with 1 message in my mailbox, it fetches it corretly, writes out its subject, then supposedly deletes it, but on the next timer tick ListMessages returns that messageInfo again and the resulting Fetch fails, with the error message “Wrong Unique Identifier”. Also, the email is not deleted, it’s still in my inbox (and my gmail account is set to delete messsages accessed by Pop3).
If I run it with an empty inbox and then send a message, it gets even more strange, for several ticks the writeline with GetMessageCount writes out 1, but no fetching since ListMessages returns an empty collection, then the fetch and delete happens, then several ticks with message count 0 where everything seems fine, but then the program tries to fetch even though messsage count was 0, it starts a fetch with the same UniqueId as that first message,and fails with the same exception. Something is very, very wrong here, this might stop me from using 3.9.0 at all…
Martin