Search code examples
javaeclipseemailswtmailto

SWT Program.launch mail client


I'm trying to create an email in the default email client of a linux mint machine and I have a problem that I can't understand. I'm using org.eclipse.swt.program.Program to launch "mailto:email@domain.com" and it partially works. It opens Thunderbird (the default email client) and it puts the mail address to "To" field but at the begining it also adds 3 slashes, and it looks like this: "///email@domain.com" which is not correct.

The code is as simple as this:

String mailTo = "mailto:" + email;
Program.launch( mailTo );

Some help will be appreciated.


Solution

  • This appears to be a bug and should be posted as such.

    However, there is a workaround/alternative:

    Runtime.getRuntime().exec("xdg-open mailto:test@test.com");
    

    xdg-open is available on most (unfortunately not all) main linux distributions and will open the default application for the given parameter.