I am displaying some data from my database on an html table. Now I want to display a link and on clicking that, I want to open outlook application just like any other mailto link, but I want the table to come as content in my email. After reading many posts I have come to know that it is not possible to send html content via mailto. So I think I will have to use Javamail API to construct a message. So I have two questions: 1. How do I construct a message via Javamail API with body having a table. 2. How do I open outlook windows App using javamail? All the examples I see on the internet are for sending the email directly.
Asked
Active
Viewed 632 times
1 Answers
0
- Why don't you want your message to be html? You can use another rich text format if you think that's better. Otherwise you're stuck with formatting the table as plain text, uses spaces to line up the columns and ASCII characters to draw lines around the columns if you want that.
- JavaMail can't open Outlook, but there are other ways to open Outlook from a Java program.

Community
- 1
- 1

Bill Shannon
- 29,579
- 6
- 38
- 40
-
Yes you are right. I can use html format. Regarding opening outlook, I am able to do it using Desktop.getDesktop. But it also takes URI and its the same as mailto. SO I cannot get html content in outlook. – nevin Feb 11 '16 at 07:41
-
If you store the draft message in a file, is there a way to tell Outlook to read that file? – Bill Shannon Feb 11 '16 at 18:40
-
Not sure if I correctly understood the work around. So you are suggesting to store the file temporarily as draft using java mail. And then open that file using Desktop class. If all of this is possible and there is no other way out, then I like the idea. I will try it. Thanks – nevin Feb 17 '16 at 11:28
-
I don't know very much about Outlook, but if you can point Outlook at a draft message file and tell it to open it in the compose window and allow you to further edit it before sending it, that would be a good workaround. You may need to use Runtime.exec instead of the Desktop class to invoke Outlook. Of course, all of this assume that you're writing a program that only ever has to work on machines that also have Outlook. – Bill Shannon Feb 17 '16 at 18:56