Opening Default Email Client from java Application on MAC OSX

Discussion in 'Mac Programming' started by singhkanhaiya, May 18, 2008.

  1. singhkanhaiya macrumors newbie

    May 18, 2008
    My aim is to open default email client on MAC OSX and Linex from java application.

    On the linex machine i am able to open the default email client using the below code.

    String[] sendEmail = {xdgEmailCommand, "--subject", Subject, "--attach", path, ""};

    currentRuntime = Runtime.getRuntime();
    currentRuntime.exec(sendEmail );

    Looking to above can you plz suggect something that I can do on MAC OSX.
  2. robbieduncan Moderator emeritus


    Jul 24, 2002
    You can use the open command in a similar fashion. Shell out as with your current code.

    The xdgEmailCommand is "open" and it takes a single argument. The get it to send a mail in the default client use a mailto: syntax like this:


    You can test this using the Terminal to get the syntax/escapes for spaces etc correct...

Share This Page