How to parse outlook email using spring - java

I have a use case where i need to read the content of the mail in outlook inbox and convert it into xml and send it to diffrent system.Is there any library which can help me in parsing the content.

Outlook is the client for the email server.(May be exchange server).
You actually need to connect to the server to read the email.
If you know the server, you can find a API for it.
Checkout this URL if you are trying to access the exchange server:
http://archive.msdn.microsoft.com/ewsjavaapi

Related

Java mail ,unable to read “.msg attachment” sent from outlook client

I met nearly same problem which mentioned in following URL
Java mail Api ,unable to read ".msg attachment" from outlook client
If anyone has a solution to read ".msg attachment" sent from outlook client by javamail (no issue if email sent from web mail console), pls. let me know.
thanks
What is the MIME type of the .msg attachment? If it's a Microsoft proprietary type, the Apache POI project may help.

Sending javamail using Office365 mail template

I want to send mail from java application using javamail through Office 365, which I am able to do.
Now my requirement is that I need to send mail using some template which is already created in Office 365 account.
Moreover I need to add some customized data on the mail template(like mail merge), which I am not able to do.
Can we send mail through javamail using some already created mail template? If so please help me how to do it?
Thanks.

Sending mail using java : file is not getting attached from local system

I am developing a web application using Oracle ADF and jdeveloper11.1.2.4. In that I have a form to send a mail with required input fields. Example toAddress, ccAddress and attachemnt Location(input text field). I am sending mails using java mail api. I got this information from the post
Mail using java
My problems is with attachment file. I am able to send an email successfully with attachment if I gave a location of the file that is on server(on which my application has deployed).
Beacause my application is web application user can access through internet. If am trying to add a location of the file that is in local system(Other than server) then file is not getting attached and mail is not getting send.
I am unable to attach a file from other than server.
Please help me. How do I achieve this. User should be able to attache a file from his/her system(local system).
First upload your file to server directory
see- http://www.awasthiashish.com/2014/08/uploading-and-downloading-files-from.html
Then provide a path when sending mail
see-http://www.awasthiashish.com/2013/04/gmail-integration-with-oracle-adf-using.html
First you will have to upload the file to the server and then attach that file in your email as JavaMail will need an absolute path on your current server.
PS: If you are sending emails using java I would highly recommend looking at Apache Commons email library https://commons.apache.org/proper/commons-email/userguide.html
It will make your life a lot easier.

Thunderbird api to send a mail via Java

I have been using Java mail API to send mails generated through the Java program. What I want to do now is to send a mail through Thunderbird mail client so that the mail get saved to the sent items folder of the user and the user can resend a mail if it has failed.
I also would like to know if it's possible to get a delivery report in the Java mail API.
Edit
I found out that our mail server is POP3 and it doesn't store mail. So is it a good idea to send another mail to the sender as well and define a rule that categorize those messages?
even if you send it with the java mail api (well gmail at least), you will still be able to see in the sent folder using thunderbird. as a matter of fact, 5 minutes ago, I saw this using a website that I build. I am sending emails using Java API, and when I check the send folder I can see them.
The InBox / Outbox in Thunderbird are normally mapped ti your IMAP-Account. The IMAP-Account is set on a mail server. All your mails and folders are stored on that mail server. the client (Thunderbird) only shows the contant from the server. By remote calls (IMAP-protocol) you can create/delete/edit/move folders and mails on the server. Sending a mail is not part of IMAP. Here you use the SMTP-Protocol. When you configure a mailaccount in Thunderbird you must configure IMAP & SMTP. When you send a mail Thunderbird does the following steps:
- Send Mail by SMTP-Protocol
- Create Mail in Outbox by IMAP-Protocol
SMTP & IMAP are totally different. But if you want to send a mail and see this mail in your outbox you must use both. You can program the same workflow with the java mail api.
If I get your question right, you are looking for a way to trigger mail sending via Mozilla Thunderbird from a Java program (an external program / software running on the same local machine).
You can achieve that via different methods:
calling the Thunderbird binary with command-line arguments
via SimpleMAPI, which Thunderbird supports
via XPCOM, also built into Thunderbird
What you won't be able to achieve easily is getting feedback from Thunderbird about the outcome of triggering / prompting the user to send a mail. But you could achieve that by using more difficult ways of integrating Thunderbird with your external software:
read and parse the actual MBOX inbox / mail sent / profile files in a user's profile. "using the X-Mozilla-Status headers (you could) figure out if a message is a new message (etc). A mbox file is essentially just a flat text file that has a seperator between the messages" (parentheses by me, source)
Write a bridging WebExtension Thunderbird Add-On that integrates in some way with your software. An extension has, via Thunderbird's WebExtensions API, essentially a hook for every feature Thunderbird has and your code Add-On could expose these internals in some way to your software.
AFAIK and sadly Thunderbird, as it ships, exposes no API or similar interface out of the box.

How to retrieve email body of any email, using Java Mail API

I am developing a Mail Client in Java (JSP and Struts). I have successfully fetched Message header information and stored in my local Database (including Message ID and subject).
When the user views the mails, I fetch the message headers from my database and display them to user. Now when the user click a particular Email, I want to fetch the mail body and file attachments from the Gmail server, directly. I don't want to serially travel through all the mails on the Gmail Server.
I have done this earlier in PHP, where if I pass the message id and I can retrieve the details of that particular mail. Is there any similar functionality in Java Mail API? If not, then can anyone suggest me a solution to this?
You can use Folder#getMessage(int) for this.
Note that the zip file with the JavaMail API which you can download from their side includes a lot of examples in /demo folder, under each a basic(!) Servlet which shows a simple mailbox with this functionality. You may want to build, refactor and expand further based on the simple example.

Categories