2

I have a java String which I need to appear in a mail body. After this message, I want to add a HTML button. How can I do this?

My string:

String customerMessage = "Hi, We have received your request. Your account will be unblocked within 48 hours.

What I want to add is after 2 lines breaks:

<a href="http://www.google.com" target="_parent">
  <button>Click me !</button>
</a>
2
  • which framework use to development ....? Commented Apr 25, 2019 at 11:17
  • You have to write the HTML code as a String... If you want to have linebreaks in HTML, then add "<br>" at the end of the HTML-Strings. Commented Apr 25, 2019 at 11:17

1 Answer 1

2

You need to write the HTML code as a String and add <br> in string for break. Like :

StringBuilder sb = new StringBuilder();
sb.append("Hi, We have received your request. Your account will be unblocked within 48 hours.");
sb.append("<br><br><a href=\"http://www.google.com\" target=\"_blank\"><button>Click me !</button></a>");
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.