1

My app sends an email from my java code. I also want to send a link within a button which will say "Activate your account".

Here is what I have:

Message message = new MimeMessage(sessionMail);
message.setFrom(new InternetAddress("test@gmail.com"));
message.setRecipients(Message.RecipientType.TO,InternetAddress.parse(user.getEmailAddress()));
message.setSubject("Account Created");
message.setText("Dear"+ user.getUserName() 
                      +" " + "\n\n  Your  Account created," 
                      + "\n\nPlease activate your account" 
                      + "<a> www.test.eu:8080/Project/"
                      + user.getToken()+"</a>");
Transport.send(message);

The following line

+ "<a> www.test.eu:8080/Project/"+ user.getToken()+" 

works as a link right now, I just want to put this link in a button and send that button to user's email.

Is there any solution for this?

I am trying this:

      message.setText("Dear"+ user.getUserName() +" "
    + "\n\n  Your Tie Account created,"

+ "\n\n Please activate your account" 
+ " <a href=www.example.eu:8080/TieProject/#!"+ user.getToken()+" >"
+" <button>Activate your Account</button> </a>"

    );
TylerH
  • 20,799
  • 66
  • 75
  • 101
junaidp
  • 10,801
  • 29
  • 89
  • 137
  • Check out this link http://stackoverflow.com/questions/2906582/how-to-create-an-html-button-that-acts-like-a-link and http://stackoverflow.com/questions/3303675/how-to-make-a-input-type-button-act-like-a-hyperlink-and-redirect-using-a-get-re – TheKojuEffect Sep 06 '13 at 04:21

2 Answers2

2

Try with something like

<a href="www.test.eu:8080/Project/"+ user.getToken()>

   <button>Activate your Account</button>

</a>
TylerH
  • 20,799
  • 66
  • 75
  • 101
TheKojuEffect
  • 20,103
  • 19
  • 89
  • 125
0

Add this html code to your message.setText() method

    <form action="http://stackoverflow.com">
        <input type="submit" value="Activate Account">
    </form>
Satyam Koyani
  • 4,236
  • 2
  • 22
  • 48