PDA

View Full Version : Opening Default Email Client from java Application on MAC OSX




singhkanhaiya
May 19, 2008, 01:46 AM
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, "mail@yahoo.com"};

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

Looking to above can you plz suggect something that I can do on MAC OSX.



robbieduncan
May 19, 2008, 03:45 AM
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:

mailto:user@domain?subject=subject

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