2016-03-03 89 views
0

我使用Spring百里香发送丰富的邮件模板。春季Rich HTML邮件与百里香

我使用下面的java和html代码。没有得到任何错误,但$值没有取代上下文值。我得到原始的html,因为它在电子邮件中。我在这里错过了什么吗?

Java代码:

final Context ctx = new Context(); 
ctx.setVariable("subject", "Welcome to App"); 
ctx.setVariable("name", fullName); 
ctx.setVariable("userEmailId", email); 
ctx.setVariable("activateLink", agentAddedUrl); 
ctx.setVariable("dialrSupportEmail", dialrSupportEmail); 
ctx.setVariable("dialerSupportNumber", dialrSupportPhone); 

final String htmlContent = templateEngine.process("agentEmailTemplate.html", ctx); 

System.out.println("HTML ==>>> "+htmlContent); 

HTML,agentEmailTemplate.html,

<!DOCTYPE html> 
<html xmlns:th="http://www.thymeleaf.org"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title th:text="${subject}">Welcome to TestApp</title> 
<style type="text/css"> 
</style> 
<script type="colorScheme" class="swatch active"> 
    </script> 
</head> 
<body paddingwidth="0" paddingheight="0" 
    style="padding-top: 0; padding-bottom: 0; padding-top: 0; padding-bottom: 0; background-repeat: repeat; width: 100% !important; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; -webkit-font-smoothing: antialiased;" 
    offset="0" toppadding="0" leftpadding="0"> 
    <table width="100%" border="0" cellspacing="0" cellpadding="0" 
     class="tableContent bgBody" align="center" 
     style='font-family: Helvetica, Arial, serif;'> 

     <div class='movableContent'> 
      <table width="520" border="0" cellspacing="0" cellpadding="0" 
       align="center"> 
       <tr> 
        <td align='left'> 
         <div class="contentEditableContainer contentTextEditable"> 
          <div class="contentEditable" align='center'> 
           <p 
            style='text-align: left; color: #222222; font-size: 14px; font-weight: normal; line-height: 19px;'> 

            <br> Hi ${name},</br> <br> Your App Admin has 
            created an account for you.</br> <br> To sign up for 
            ContactCentral Account Agent Access,click here and create your 
            own password .Your username is ${userEmailId} . </br> <br> <br> 
            Have questions? Get in touch with us via ${dialrSupportEmail} 
            or call ${dialerSupportNumber}.</br> 
            </br> <br> <br> Cheers,</br> 
            </br> <br> <span style='color: #222222;'>App Accounts 
             Team</span></br> 
           </p> 
          </div> 
         </div> 
        </td> 
       </tr> 
      </table> 
     </div> 
    </table> 
</body> 
</html> 

回答