JAVA:在邮件发送按钮(JAVA:send button in email)

2019-10-18 14:43发布

我的应用程序从我的Java代码发送电子邮件。 我也想一个按钮,将显示“激活帐户”内发送一个链接

这里是我有:

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);

下面的行

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

现在工作为纽带,我只想把这个链接在一个按钮,发送按钮,用户的电子邮件。

对此有任何解决方案?

我试图此

                  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>"

                );

谢谢

Answer 1:

喜欢的东西尝试

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

<button >激活您的帐户</button >

</a >



Answer 2:

这个HTML代码添加到您的message.setText()方法

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


文章来源: JAVA:send button in email