Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to make java string bold and colored

I am developing email application using java. I have a string as follows :

String msg= "College Email \nHello"+" "+name+"\n"+"You are selected As 'Admin'.\n Please use Given username and password for login\n \Username:"+" "+username+" "+"Password:"+" "+password+"";

I want send this string as email message. and i want to "BOLD and color" username and password(I want to show this message in inbox i.e on browser). how can i embed HTML tags to do this ? OR is there any simple way to do this without using HTML tags ?

Can any one correct above string (msg) OR provide any link or code to fix this problem ?

thank you.

like image 632
Rohhit Avatar asked Sep 15 '25 11:09

Rohhit


1 Answers

Just type the tags into your message like String msg = "<strong>Hello World!</strong> and send it as a HTML message, you only need to set type of the content via MimeMessage#setContent() method like

message.setContent(msg, "text/html; charset=utf-8");`
like image 172
Petr Mensik Avatar answered Sep 18 '25 08:09

Petr Mensik