Thanks for your attention in analysis of my code example and show one solution.
I try to change my code to following your example (Replace ExtractMessage for ExtractProperty) and i have a better performance in execution, from 24 hours to 10 hours until the finish the execution.(Not is a good time for ends go to the production)
But in another case i tested other flow, copy the original pst file two times, and: in original pst file i delete the e-mails received more than 30 days
in first copy from original pst i keep for backup purpose
in second copy from original pst i delete the e-mails received until than 30 days.
This way have the same result.
Look the code in attachment:
Now basicly the loop is:
*******************************************************************************
foreach (MessageInfo messageInfo in messageInfoCollection)
{
if (pst.ExtractProperty(messageInfo.EntryId, MapiPropertyTag.PR_MESSAGE_DELIVERY_TIME).GetDateTime() <= DateTime.Now.AddDays((Convert.ToInt32(cmbDias.Text) * -1)))
{
//Grava algumas informaçóes de LOG
log.gravaLog("[LENDO-MSG-PST-TRABALHO]", "mensagem: " + messageInfo.Subject + "....", "");
log.gravaLog("[LENDO-MSG-PST-TRABALHO]", "Remetente:." + messageInfo.SenderRepresentativeName, "");
//Logar e Deletar a mensagem do folder antigo
log.gravaLog("[DELETANDO-MSG-PST-TRABALHO]", "Deletando Mensagem" + messageInfo.Subject + "....", Environment.NewLine);
folderInfo.DeleteChildItem(messageInfo.EntryId);
}
}
*******************************************************************************
but the process still remains slow and in some cases show this exception message:
Arithmetic operation resulted in an overflow ( Translated from Portuguese/BR message)
Maybe the problem in this case is a DeleteChildItem Method,
n other test i only copy (AddMessage to other pst) messages not use DeleteChildItem throw the same loop and i have a good performance.
Thanks