0
votes

I am working with below code to get the email template from my application. When i run this i should get a filled email template(to, from, subject, body and so on.,). But in body i have some links but that is also taken as string since i took variable mailto as String.

After sending the email this hyperlink will be generated in the recipient mail box. But i want to get hyper link when the email is created in the client side. Here www.google.com should be shown as hyperlink and it should redirect to google.com when i click the link.

My Code Snippet:

import java.awt.Desktop;

String mailBox = "[email protected]";
String mailTo = mailBox + "?cc=" +  systemProperties.getProperty("user.name") + "&SUBJECT=Title name!";
  mailTo += "&BODY=<<Test body starts **http://www.google.com** Test body ends>>\n\n\n\n\n\n\n\n\n\n"
      + footer;

  URI uriMailTo = null;
  try
  {
    if (mailTo.length() > 0)
    {
      uriMailTo = new URI("mailto", mailTo, null);
      desktop.mail(uriMailTo);
    }
    else
    {
      desktop.mail();
    }
  }

Is there any way to get the hyper link with the above code????

1

1 Answers

0
votes

you need to use basic html for the body of the mail.

    String mailTo = mailBox + "?cc=" +  systemProperties.getProperty("user.name") + "&SUBJECT=Title name!";
  mailTo += "&BODY=<<Test body starts ** <a href ='http://www.google.com'>clieck </a>** Test body ends>>\n\n\n\n\n\n\n\n\n\n"
      + footer;

Try and tell me how it works. Just post the body part as html

<a href="http://google.com> google </a>

Like wise