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

Free Support Forum - aspose.com

Read & Write Outlook MSG files in Java Applications without using Microsoft Outlook®

I just found this but iam actually searching for a solution to read
and write outlookfiles which are currently in use, do you have a
solution for this?

Thanks a lot

Bernhard Rutkowsky


This message was posted using Email2Forum by ShL77.

Hi Bernhard,


Thanks for considering Aspose.

By “currently in use” do you mean the files are opened in some other process?

I just tried to load an MSG file using Aspose.Network for Java, which was already opened in MS Outlook 2007. I was able to load the file, get its contents and extract attachments. But if I save the file with the same folder/name, it would not do it and throw exception “the file is opened in another process”.

You may perform read operations on the files which are in use with another process. Saving with same name/location will give error. But you may successfully save it with another name/location.


String strMsg = “message-1.msg”;
// load msg file from disk
MapiMessage msg = MapiMessage.fromFile(strMsg);
// read properties
System.out.println("Subject: " + msg.getSubject());
System.out.println("From: " + msg.getSenderName() + " " + msg.getSenderEmailAddress());
// display recipients name and email addresses
MapiRecipientCollection recipientColl = msg.getRecipients();
for(int i=0 ; i<recipientColl.size() ; i++)
{
MapiRecipient rec = (MapiRecipient)recipientColl.get(i);
System.out.println("To: " + rec.getDisplayName() + " " + rec.getEmailAddress());
}

// msg.save(“message-1.msg”); // won’t work, if the file is opened in another process/application
msg.save(“message-2.msg”); // this will work