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

Free Support Forum - aspose.com

Undelete doesn't work?

It seems like the “Undelete” method doesn’t do what it says on the tin.



In short, I made a quick test where i call “ListMessages”, loop through these, and fetch the individual messages.



While listing the fetched messages, I deleted one of them.



When fetching all messages once more, the count was reduced by 1, as expected.



Then I did an “Undelete”, and finally fetched all the messages once more. Still the original count was reduced by 1.



When running the test once more, without the “Delete”/“undelete” code, my message seems to be permanently gone.



I’ve attached the code (the delete/undelete is currently commented out).

Hi Morten,


I have analyzed the issue you have shared with us. However, I have noticed that the message isn’t deleted from the server. In my test accounts I have 2 messages. After fetching first message, I deleted it and then performed undelete. At this stage, the ListMessages shows total messages in Inbox as 1, but the next time when application is run, it again shows 2 messages in the inbox. This might be related to the transaction completion time required by server. Could you please share which server you are using for testing purpose?I have tested the scenario with Microsoft Exchange Server using the latest version of Aspose.Email for .NET 4.2.0.

Sample Code:

<span style=“font-size:10.0pt;font-family:“Courier New”;color:#2B91AF;mso-no-proof:
yes”>Pop3Client
<span style=“font-size:10.0pt;font-family:“Courier New”;mso-no-proof:yes”> client =
GetAsposePopClient();<o:p></o:p>

Pop3MessageInfoCollection coll = client.ListMessages();

Console.WriteLine("Total Messages: " + coll.Count);

foreach (Pop3MessageInfo msgInfo in coll)

{

Console.WriteLine(msgInfo.SequenceNumber + "." + msgInfo.Subject);

}

Console.WriteLine("*********************************************");

Console.WriteLine("Fetching First Message...");

client.FetchMessage(coll[0].SequenceNumber);

if (coll.Count > 0)

{

Console.WriteLine("Deleting " + coll[0].Subject);

client.DeleteMessage(coll[0].SequenceNumber);

Console.WriteLine("*********************************************");

Console.WriteLine("After Deletion..");

coll = client.ListMessages();

Console.WriteLine("Total Messages: " + coll.Count);

Console.WriteLine("*********************************************");

Console.WriteLine("Performing Undelete...");

client.UndeleteMessages();

Console.WriteLine("After Undelete...");

coll = client.ListMessages();

Console.WriteLine("Total Messages: " + coll.Count);

}


I appreciate your quick response!

I’m running Aspose.Email 4.1.0.0 against an in-house Exchange 2010 server (2010 SP3 RU2).



When running your code, I am also unable to reproduce my original question.
However, there’s one crucial difference between my and your code - something I forgot to include in my original post;
When I’m done, I perform “client.Quit()”, whereas you don’t do anything.

When including “Quit”, the messages marked as deleted at some point are in fact deleted, even though they have later been “undeleted”.
“UndeleteMessages” explicitly states that any messages marked as deleted will get this mark removed, and “Quit” states that the connection is closed, and that any messages marked as deleted will be deleted.

Hi Mortan,


Thank you for the explanation.

1. The issue that I mentioned in my posting above has been logged as NETWORKNET-34401 in our bug tracking system for rectification.

2. The use of Quit() command closes the current transaction, due to which server completes all the tasks that are marked for action. Hence, the messages are deleted and UndeleteMessages() have no effect in turn.

kashif.iqbal:

2. The use of Quit() command closes the current transaction, due to which server completes all the tasks that are marked for action. Hence, the messages are deleted and UndeleteMessages() have no effect in turn.



Thank you for the reply, but it still seems pretty weird that "Quit" should behave this way. If that will be the case, maybe the API docs should be clear on this?

So, shouldn't I do anything when finished with the transaction? Not even "Disconnect"?
In your sample solution, some of the samples use "Disconnect", while the majority don't.
But then again, all samples use the now obsolete "Connect" method.

In fact, testing has shown that when calling "DeleteMessage", these messages will persist if "client.Disconnect" is called, or nothing at all.
In order to actually delete anything, "Quit" has to be called. This makes "UndeleteMessage" risky to use...

Please advise...

Hi,


As per the API documentation (also can be seen in offline CHM help file), the POP3 server removes all messages marked as deleted then closes the TCP connection.

In case you want to permanently delete the messages marked as deleted, you can call the Pop3Client.CommitDeletes() method and, hence, it is not necessary to call “Quit” for actually deleting messages. With respect to documentation articles containing calls to the “Connect” method, we have modified these already and if you still notice any such occurrence, please point us to that for rectification.

I really appreciate your efforts to answer my questions, but I still haven’t got a clear understanding of a few things:

1) To end a session, should I, or should I not, use “Quit” - or should I use “CommitDeletes” instead? As far as I’ve verified, I need to do something, or else everything is just rolled back.
I haven’t tested the “UndeleteMessages” scenario together with “CommitDeletes”, so I don’t know how that behaves.

2) To clarify my API comments: I said that if it really is so that “Quit” IGNORES the commands issued by “UndeleteMessages”, then the API doc for “Quit” should say so! Or else the users might be led astray, as I was.

3) Can you show me a scenario where “UndeleteMessages” actually works, preferably in combination with doing other deletes after “UndeleteMessages”?

4) Your samples STILL use the obsolete “Connect”. See “https://github.com/asposeemail/Aspose_Email_NET”, linked to from “http://www.aspose.com/github-repositories.aspx”.
Also, the latest VS version in your samples is VS2010.

Hi Mortan,

1. The Delete operation can be completed by using either CommitDeletes() or Quit() or Dispose(). For ending session, you have to use quit or dispose. In addition, when one commits delete messages, it also ends a session. If CommitDeletes() is used, you don’t need to invoke Quit operation, though the more correct use is Dispose().

2. Thank you for the clarification.

3. I am afraid but until the fix of NETWORKNET-34401 is available, I am unable to produce such a sample for demonstration. This issue has been fixed already and will be part of our upcoming release which will be available for download at the end of this or early next week.

4. We’ll update the examples soon as the task is already under progress.

The issues you have found earlier (filed as NETWORKNET-34401) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.