PST export from Outlook outputs error "Some items cannot be copied."

After saving emails to a PST file using Aspose PST, the PST file can be opened in Outlook, and I seem to be able view messages. However, If I then export the data from Outlook to another PST file, it comes up with the error “Some items cannot be copied. They were either moved or deleted, or access was denied”. Thus, it seems the emails cannot be exported again from Outlook, like emails in a PST originally created inside Outlook can.

The attached PST file jamie_pst.zip (4.7 MB)
was created using Aspose PST.

To reproduce the export error, open the PST in Outlook. Inside Outlook, click File->Open & Export-> Import/Export -> Export to a file & click Next -> Outlook Data File & Next -> Select jamie top node & click Next. An error will popup saying “some items could not be copied”. Can you please advise? Thanks.

Hello @jamie-1,

Thank you for providing PST file.
Are you create this pst from scratch or add items to a previously created (by Outlook) file?
Please share the code example. Thanks.

The PST file is created from scratch. I don’t have a test case (if that’s what you are after), however, I can share the production code to give you an idea of how we use the Aspose lib.PSTExportFile.zip (3.1 KB)

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): EMAILNET-40952

You can obtain Paid Support services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@jamie-1,

The issue was reproduced on our side, but all items were correctly exported from the backup.pst.
In our tests we tried to recreate a new PST with identical structure and messages, but the issue did not reproduce with the new PST.
Perhaps you have parts of the code with PST modifications that are not in your code sample.

The “PreserveTnefAttachments” Load Option is enabled in your code sample.
In this case winmail.dat is always attached to the resulting MSG instead of correct Outlook Message loading:

loadOptions.setPreserveTnefAttachments(true);

“PreserveTnefAttachments” Load Option description:

If a message contains a TNEF attachment (winmail.dat) and has the MIME type application/ms-tnef, then this property defines whether files from TNEF will be decoded and extracted. The winmail.dat attachment remains as it is if the property value is true.

We also wanted to pay attention to the moment of optimization.
In your code sample messages added one at a time:

pstFolder.addMessage(mapimsg);

If you add all messages at once, it will speed up the process many times over:

List<MapiMessage> messages = new ArrayList<MapiMessage>();
messages.add(new MapiMessage());
messages.add(new MapiMessage());
//...
pstFolder.addMessages(messages);

Thank you for investigating. Its strange that you could export the data, since we don’t actually have additional parts of code outside the sample provided with further PST modifications. In regards to using pstFOlder.addMessages(messages) for additional performance, since multiple message objects will reside in memory, won’t this approach potentially consume a large amount of memory assuming there are thousands of messages in a given folder?

@jamie-1,

In our tests we used all messages and its folder’s structure exported from the jamie.pst storage.

In regards to using pstFOlder.addMessages(messages) you can use Iterable interface.

class MessageStoreIterator implements Iterator<MapiMessage> {

    private DataStorage store;

    public MessageStoreIterator(DataStorage store) {
        this.store = store;
    }

    @Override
    public boolean hasNext() {
        return store.hasNextMessage();
    }

    @Override
    public MapiMessage next() {
        return store.nextMessage();
    }

    @Override
    public void remove() {
    }
}

try (PersonalStorage pst = PersonalStorage.create("jamie.pst", FileFormatVersion.Unicode)) {
    FolderInfo folder = pst.getRootFolder().addSubFolder("Inbox");

    folder.addMessages(new Iterable<MapiMessage>() {
        @Override
        public Iterator<MapiMessage> iterator() {
            return new MessageStoreIterator(new DataStorage("jamie"));
        }
    });
}