ricgeorge
ricgeorge

Reputation: 188

Use html mailto href in java

I have a String on a JOptionPane dialog using the following html:

String email= "<html>"  + "<html><b>John Smith" + "\n<html><a href=mailto:[email protected]>[email protected]</a>";

This highlights the email address in blue with an underline as one would expect in html, but I thought it would be clickable, opening the default mail client with a new message using the email address provided, but it does nothing.

Is there a way to do this?

Upvotes: 0

Views: 991

Answers (1)

Akber Choudhry
Akber Choudhry

Reputation: 1785

Create a handler on the click and call the Desktop API to invoke the OS default mail client:

http://docs.oracle.com/javase/7/docs/api/java/awt/Desktop.html#mail()

Upvotes: 1

Related Questions