How Can I put a HTML link Inside an email body?

前端 未结 5 2029
伪装坚强ぢ
伪装坚强ぢ 2021-02-19 07:59

I have an application thats can send mails, implemented in Java. I want to put a HTML link inside de mail, but the link appears as normal letters, not as HTML link... How can i

5条回答
  •  爱一瞬间的悲伤
    2021-02-19 08:33

    Adding the link is as simple as adding the text inside the string. You should set your email to support html (it depends on the library you are using), and you should not escape your email content before sending it.

    Update: since you are using java.mail, you should set the text this way:

    message.setText(body, "UTF-8", "html");
    

    html is the mime subtype (this will result in text/html). The default value that is used by the setText(string) method is plain

提交回复
热议问题