Change color in part of my message

I need to change the text color for a specific word in my text. I used to generate my text as shown below.

String message=string.empty; String message1="something"; String message2="something"; message += "My Message is"+ message1+ "and" + message2; 

and I am sending this message as an email body. Therefore, I need to change the color of the text only part of this message. Suppose I want message2 to be red. How can i do this? Thanx.

+4
source share
4 answers

You can only do this if you are sending a message in HTML format. And then the code will be

 string message1 = "something"; string message2 = "<font color='red'>something</font>"; message += "My message is " + message1 + " and " + message2; 

Using HTML in email is different than using HTML to create web pages. Many no-no web pages are a must in the mail: |

+3
source

If you send an email in HTML format, you can use regular HTML tags to achieve your goal (in the actual body of the message). Therefore you can write:

 ...+= "My Message is" + message1 + "and <font color=red>" + message2 + "</font>"; 
0
source

If the email supports the html body, you can try wrapping the part of the message that you want to tag in the html <font color="red"></font> tags and then checking whether the resulting output will function as expected.

0
source

If you send an HTML email address, you can use standard HTML tags, such as the font tag:

 <font color="red">Some text!</font> 

Or you can use CSS:

 <h3 style="color: #FF0000;">Some text!</h3> 

If you send a text email, there is no way to format your body.

0
source

Source: https://habr.com/ru/post/1337316/


All Articles