I'm looking for the easiest way to open the system default mail client with a custom message.
Is there some way to make this OS independent?
You may use the Desktop class for this, it has a mail(URI)
method.
Launches the mail composing window of the user default mail client, filling the message fields specified by a mailto: URI.
Here is an example :
Desktop desktop = Desktop.getDesktop();
String message = "mailto:someuser@somedomain.com?subject=mySubject&body=someBody";
URI uri = URI.create(message);
try {
desktop.mail(uri);
} catch (IOException e) {
e.printStackTrace();
}