I am currently looking into copying public folders and the containing emails from a MS exchange server 2003 to a local directory in window explorer, in the same structure, so I will then have the directories and the .msg files on my local drive.
I have researched this, but unsure what route to go down. MAPI, Webdav, IMAP, Javamail etc.
I will be creating a Java app to do the copying also. Also open to any other software development recommendations (Perl, C++)
What would be the best protocol to do this and also anyone got any links where I can do some more research on this subject?
Many thanks
JavaMail can't create .msg files, which are a proprietary Microsoft format, so if that's a key part of your requirements you'll need to look at something else.
If a .eml file (effectively a MIME format file) or a Unix mail format file would be sufficient, you can consider JavaMail.
JavaMail includes a demo program that copies a mailbox hierarchy from one store to another.
There are several options for storing messages locally.
Run an IMAP server on the local machine. This is probably the easiest.
Use a local store provider, such as the JavaMail mbox provider or another such provider from the JavaMail Third Party Products page.
Write your own code to store each message to disk using the MimeMessage.writeTo method.
Hope that helps.
Related
I need to get contact list from Outlook Exchange. The problem is that I have to use Java and I totally don't know where to start. Can anyone tell me what I have to do firstly?
How can I programmaticaly connect to Outlook?
If you are running on Windows you can probably use JaWin. It is an open source library that wraps COM object and provides you a Java API to access them. As far as I remember its distribution contains example of how to connect to MS Exchange server.
Other similar packages I know are
Jintegra (costs some money)
Jinterop (open source too)
Both libraries implement DCOM protocol in Java, so you can run application that uses them on any platform and connect to exchange server.
Other way is to use POP3 or SMTP protocol also supported by Exchange. There are a lot of packages that support them, e.g. JavaMail.
And the last way: if your application is running on client side, i.e. on the client's computer it can parse files created by outlook itself. I do not remember where these files are stored but I remember that many years ago I have discovered the issue and saw that all emails are stored in file system in clear text format.
EDIT: Recently I found out JACOB: other library that uses JNI (like JaWin).
I need a way to read the stored emails in Thunderbird with Java and retrieve attached files.
The problem is that I have an old FoxPro app that reads Zip files from a folder. The FoxPro used to retrieve those files from attachments into the emails in Outlook Express, when we installed Outlook 2007 this function of retrieve the files from Outlook didn't work anymore so it was replaced with a simple Java app (reading directly from the PST file). So now FoxPro app executes the Java app to retrieve those files.
Now I want to replace Outlook 2003 with Thunderbird and I want to read the emails from there.
IMPORTANT: The accounts are POP3 so I can't use IMAP to extract files directly from the email server.
There is a lib or something?
As best I know there is no Java support, directly or by 3rd party library. Having said that, I've looked at the way emails are persisted onto disk and you should be able to access those files directly with a Java app. Attachments are stored inline and although I haven't tried to code an extraction app in Java, the structure and syntax of the attachments reminded me of the way attachments are stored in newsgroups (access via NNTP).
Thunderbird stores messages in mbox (loosely described in RFC 4155) files, with separate files for index/flags. GNU JavaMail should be able to read the mail store. That's just the first implementation I found, it may not be that hard to write another one.
Programatically using Java, is it possible to download and save emails from Exchange Server as .msg files?
If not, are there any formats possible, which can be opened with Outlook
The solutions received were commercial options which for me is out of scope right now.
The second part in my question was if I can save in any other format. I have figured out that I can save them as .eml file which also can be opened in Outlook. This will solve the problem for me.
You can use Outlook Object Model (see MailItem.SaveAs) if you have a local Outlook profile configured to access the Exchange mailbox in question.
You can also use Redemption (I am its author) to dynamically connect to an Exchange mailbox (RDOSession.LogonExchangeMailbox), iterate through the messages and save them in the MSG format (RDOMail.SaveAs).
I want to create a JAVA application which will access my MS Outlook and download attachments from some received mails. I can not access the MS Exchange server directly and thus I plan to connect to local copy of MS Outlook installed on the machine, and then access the folder and mails from there.
The problem is I can not get any good open source libraries to connect to outlook frommy java application.
After a lot of research I found it can be done using JACOB, but it looks like an old library and I am not sure whether I should use it.
Any suggestions/ideas to get it done? I am not allowed to connect to Microsoft Exchange Server directly so JAVAMAIL is of no use..:(
I also got this code snippet but I can't make anything out of it.
Aspose.Email also be helpful, but it is not open source. I have not tried the outlook part of it though.
http://www.aspose.com/java/total-component.aspx
I am trying to save a whole mailbox onto disk using the JavaMail API (in essence, perform a full backup_. I can successfully read all the relevant folders into memory and then sever the connection to my mail server. What I can't figure out is how to actually store the folders and/or individual messages if need be on my disk.
I've tried searching around and came up with an interesting link (below) but can't figure this out. Does anyone have any advice on where to get started? I appreciate it, thanks
http://www.oracle.com/technetwork/java/javamail/faq/index.html#serialize
quick note: I tried using a class that contained an ArrayList of type Folder(JavaMail class) and make that serializable, but I still had an exception thrown when I tried to write to disk. I've been working on this problem for about two days now and I could use some pointers. Thanks!
You found the FAQ, but you missed this entry:
How do I store mail messages on my local disk?
And, as the FAQ entry you found says, you can't just serialize the Message objects, let alone the Folder objects.
If all this seems too complicated for you, the simplest approach might be to get an IMAP server that you run on your local machine, then copy the messages from your remote IMAP server to your local IMAP server. The JavaMail FAQ has pointers to IMAP servers you can install locally, and a little web searching will turn up more. JavaMail also comes with a demo program (populate.java) for copying folders.