Anushka lakmal
Anushka lakmal

Reputation: 91

HTML Button Not redirecting into given link in Java mail body

I want to add a button to HTML email template I'm creating. I already created a button but when I click on it, the link does not appear. Can anyone help me with my problem?

Here is my code:

messageBodyPart.setContent("<h1>You Have a Promotion</h1> <h3>Your First Name :</h3>" + FirstNm + 
                      "<h3>Your Last Name :</h3>" + LastNm + "<h3>Your Employee ID :</h3>" + Employeeid + 
                      " <br/> <form>\r\n" + 
                            "<input class=\"MyButton\" onclick =\"http://localhost:8080/update/status/password/ACCEPT\" type = \"button\" value =\"Accept Your Promotion\" />\r\n" + 
                      "</form>","text/html");

Upvotes: 0

Views: 592

Answers (2)

Tariqul Islam
Tariqul Islam

Reputation: 347

You can use input like this: <input type="button" onclick="window.location='https://www.yourdomain.com/'" value='Go'>

<html>
	<head></head>
	
	<body>
	
		<input type="button" onclick="window.location='https://www.yourdomain.com/'" value='Go'>
	</body>
</html>

Upvotes: 0

95faf8e76605e973
95faf8e76605e973

Reputation: 14191

Try to add anchor tags and with an href attribute instead of an onclick event on the input element.

messageBodyPart.setContent("<h1>You Have a Promotion</h1> <h3>Your First Name :</h3>" + FirstNm + 
                      "<h3>Your Last Name :</h3>" + LastNm + "<h3>Your Employee ID :</h3>" + Employeeid + 
                      " <br/> <form>\r\n" + 
                            "<a href=\"http://localhost:8080/update/status/password/ACCEPT\"><input class=\"MyButton\"  type = \"button\" value =\"Accept Your Promotion\" /></a>\r\n" + 
                      "</form>","text/html");

Upvotes: 1

Related Questions