title: Sending email with Template using Spring boot
body: <p>I have created the simple spring boot application and trying to send email using email template but its throwing:</p>
  
  <p><code>org.thymeleaf.exceptions.TemplateInputException: Error resolving template "email-simple.html", template might not exist or might not be accessible by any of the configured Template Resolvers.</code></p>
  
  <p>I also used thymeleaf classpath in <code>application.properties</code></p>
  
  <pre><code>spring.thymeleaf.prefix=classpath:/templates
  </code></pre>
  
  <p>But i keep getting the same exception. Can any body know the solution pl help me. 
  Below is the source code i am using.
  (1) I used Thymeleaf in pom.xml
          <code>&lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-thymeleaf&lt;/artifactId&gt;
          &lt;/dependency&gt;</code></p>
  
  <p>(2) I kept my email-simple.html file in the resources/templates/email-simple.html.</p>
  
  <p>(3) here is my Service class:</p>
  
  <pre><code>@Component
  public class SmptMailSender {
  
  @Autowired
  private JavaMailSender javaMailSender;  
  
   @Autowired 
   private TemplateEngine templateEngine;
   public void sendSimpleMail(final String recipientName, final String    recipientEmail, final Locale locale) 
              throws MessagingException {
  
          // Prepare the evaluation context
          final Context ctx = new Context(locale);
          ctx.setVariable("name", recipientName);
          ctx.setVariable("subscriptionDate", new Date());
          ctx.setVariable("hobbies", Arrays.asList("Cinema", "Sports", "Music"));
  
          // Prepare message using a Spring helper
          final MimeMessage mimeMessage = this.javaMailSender.createMimeMessage();
          final MimeMessageHelper message = new MimeMessageHelper(mimeMessage, "UTF-8");
          message.setSubject("Example HTML email (simple)");
          message.setFrom("thymeleaf@example.com");
          message.setTo(recipientEmail);
  
          // Create the HTML body using Thymeleaf
          final String htmlContent = this.templateEngine.process("email-simple.html", ctx);
          message.setText(htmlContent, true /* isHtml */);
  
          // Send email
          this.javaMailSender.send(mimeMessage);
  
      }
  </code></pre>
  
  <p>}</p>