Reputation: 2285
I'm trying to change the color of a string that I'm sending out as part of the email using an email service, but I can't find any good resources on doing so. Here's the code that I have now:
String message = "hello world";
emailObject.setBody(message);
emailService.sendEmail(emailObject);
I want "hello world" to appear let's say, in red text, instead of the default black text. How would I accomplish that?
Upvotes: 0
Views: 649
Reputation: 9424
Try something like this:
String message = "<span style=\"color: #FF0000\">hello world</span>";
You just need to use HTML markup in your text.
To make HTML work you will need to change the content type to "text/html", sayind to you email client that the content should be redered as HTML, not as plain text.
Edit.
You will need to use MimeMailMessage, MimeMessage and MimeMessageHelper to use HTML in your messages. Next time, try to explain more your problem, saying the API that you are using, showing more code, etc.
You can find some examples at the docs.
Upvotes: 2
Reputation: 1095
try...
String message = "<span style='color:red;'>hello world</span>";
Upvotes: 0