Free Support Forum -

FolderInfo.deleteChildItem throwing exception


I have the following piece of code:

for (int k = 0; k < messageInfoCollection.size(); k++)
MessageInfo messageInfo = (MessageInfo) messageInfoCollection.get_Item(k);
MapiMessage message = pst.extractMessage(messageInfo);

String bsId = message.getHeaders().getDecodedValue(“X-MSGID”);

if (bsId.equals(
console.println(Console.output, “DELETED_EMAIL||” + folder.fullPath + “||” + pstFile.FormatSubject(it_local.subject));




When running it, it deletes the message from folder, but also throws the following exception:

Could not read message. The message data is probably corrupted.

What can I do to avoid this exception?



I found the solution, it was my fault.
After deleting the message, I have to call this function again to rebuild messageInfoCollection:

messageInfoCollection = targetFolder.getContents();

Thanks for your attention


It’s good to know that things are resolved on your end. Please feel free to contact us if you have any further inquiry in this regard.