This is what iam currently doing:
private void openEmailButtonMouseClicked(MouseEvent e) {
String mailto = getClientConfigValue("email", "mailto");
String ccto = getClientConfigValue("email", "ccto");
String subject = getClientConfigValue("email", "subject");
String body = getClientConfigValue("email", "body");
String currClient = getCurrClient();
String bodyPath = getSpecificClientConfigPath(currClient) + body;
String text = "";
try {
BufferedReader br = new BufferedReader(new FileReader(bodyPath));
try {
StringBuilder sb = new StringBuilder();
String line = br.readLine();
while (line != null) {
sb.append(line);
sb.append(System.lineSeparator());
line = br.readLine();
}
text = sb.toString();
while (text.contains(" ")) {
text = text.replace(" ", "%20");
}
text = text.replaceAll("(\r\n|\r|\n|\n\r)", "%0A");
}
finally {
br.close();
}
}
catch (Exception e1) {
e1.printStackTrace();
}
try {
Desktop.getDesktop().mail(new URI("mailto:" + mailto + "?subject=" + subject + "&cc=" + ccto + "&body=" + text));
}
catch (Exception e1) {
e1.printStackTrace();
}
}
It works perfect for .txt and .doc(without text formation). But still its not quite satisfying since i cant send formatted text to the standart desktop email cleint, because im forced to generate an url. Does anybody know a way to parse formatted text to the email client via mailto or anything else?