JAVA:send button in email

China☆狼群 提交于 2019-12-11 13:26:59

问题


My app sends an email from my java code . I also want to send a link within a button which will say "Activate your account"

Here is what i have:

Message message = new MimeMessage(sessionMail);
message.setFrom(new InternetAddress("test@gmail.com"));
message.setRecipients(Message.RecipientType.TO,InternetAddress.parse(user.getEmailAddress()));
message.setSubject("Account Created");
message.setText("Dear"+ user.getUserName() 
                      +" " + "\n\n  Your  Account created," 
                      + "\n\nPlease activate your account" 
                      + "<a> www.test.eu:8080/Project/"
                      + user.getToken()+"</a>");
Transport.send(message);

The following line

+ "<a> www.test.eu:8080/Project/"+ user.getToken()+" 

works as a link right now, I just want to put this link in a button and send that button to user's email.

Is there any solution for this?

i am trying this

                  message.setText("Dear"+ user.getUserName() +" "
                + "\n\n  Your Tie Account created,"

            + "\n\n Please activate your account" 
            + " <a href=www.example.eu:8080/TieProject/#!"+ user.getToken()+" >"
            +" <button>Activate your Account</button> </a>"

                );

Thanks


回答1:


Try with something like

<a href="www.test.eu:8080/Project/"+ user.getToken()>

<button>Activate your Account</button>

</a>




回答2:


Add this html code to your message.setText() method

    <form action="http://stackoverflow.com">
        <input type="submit" value="Activate Account">
    </form>


来源:https://stackoverflow.com/questions/18649812/javasend-button-in-email

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!