Answers.Body: <p>The template path needs to include your plugin folder name. So in your case the path to your email templates would be <code>pluginname/templates/emails/prospect</code> and the path you pass to <code>render()</code> would be <code>pluginname/emails/prospect</code>.</p>
  
  <p>More info: <a href="https://craftcms.com/docs/plugins/templates#plugin-template-paths-explained" rel="nofollow noreferrer">Plugin template paths explained</a></p>
  
  <p>But that doesn't explain why the first template path appears to work.</p>
  
  <p>I’d probably keep the templates inside my plugin if they weren’t being used from the front-end. However, if you'd like to change the default template path to your front-end template directory <a href="https://craftcms.stackexchange.com/questions/4353/rendertemplate-in-a-plugin-for-front-end-request-using-front-end-template">this answer</a> will help.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-06-06T14:47:25.813Z
Answers.Text: Thanks Luke - have tried with plugin template paths but still getting error `Unable to find the template “emails/prospect”.`
Answers.UserDisplayName: Cole Henley
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-06-06T15:01:30.617Z
Answers.Text: Need to use `craft()->templates->render( 'pluginname/templatename' );` so plugin name and then leave out your templates directory. I've updated my original answer.
Answers.UserDisplayName: Luke Pearce
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-06-06T15:11:07.810Z
Answers.Text: Thanks Luke! Fixed by updating template path:
  
       `$path = craft()->path->getSiteTemplatesPath();`
       `craft()->path->setTemplatesPath($path);`
Answers.UserDisplayName: Cole Henley
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-06-06T14:40:55.270Z
Answers.LastActivityDate: 2016-06-06T15:04:41.867Z
Answers.LastEditDate: 2017-04-13T12:51:00.160Z
Answers.UserDisplayName: Luke Pearce
Body: <p>I've got a plugin which am triggering emails from (listening to the <code>users.onSaveUser</code> event).</p>
  
  <p>I am using a conditional to send two emails, depending on the permissions of the person registering the user.</p>
  
  <p>In one instance am using <code>$email-&gt;htmlBody = craft()-&gt;templates-&gt;render('emails/employee', $vars);</code> which works fine.</p>
  
  <p>However, in another instance am using <code>$email-&gt;htmlBody = craft()-&gt;templates-&gt;render('emails/prospect', $vars);</code> and getting the following error:</p>
  
  <pre><code>Unable to find the template “emails/prospect”.
  </code></pre>
  
  <p>Any ideas why this might be happening or how to get more useful feedback?
  I have double and triple-checked the spelling of the files and they are indeed available in the file system:</p>
  
  <p><a href="https://i.sstatic.net/nckRq.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/nckRq.png" alt="finder screenshot"></a></p>
  
Tags: <plugin-development><templating><emails>
Title: Render Template issue
ThreadText: # Render Template issue
  
  (Asked by: username_0 on 2016-06-06)
  
  I've got a plugin which am triggering emails from (listening to the `users.onSaveUser` event).
  
  I am using a conditional to send two emails, depending on the permissions of the person registering the user.
  
  In one instance am using `$email->htmlBody = craft()->templates->render('emails/employee', $vars);` which works fine.
  
  However, in another instance am using `$email->htmlBody = craft()->templates->render('emails/prospect', $vars);` and getting the following error:
  
  ```
  Unable to find the template “emails/prospect”.
  
  ```
  
  Any ideas why this might be happening or how to get more useful feedback?
  I have double and triple-checked the spelling of the files and they are indeed available in the file system:
  
  [![finder screenshot](https://i.sstatic.net/nckRq.png)](https://i.sstatic.net/nckRq.png)
  
  **Tags:** plugin-development, templating, emails
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-06-06. Score: 3 | Accepted answer
  
  The template path needs to include your plugin folder name. So in your case the path to your email templates would be `pluginname/templates/emails/prospect` and the path you pass to `render()` would be `pluginname/emails/prospect`.
  
  More info: [Plugin template paths explained](https://craftcms.com/docs/plugins/templates#plugin-template-paths-explained)
  
  But that doesn't explain why the first template path appears to work.
  
  I’d probably keep the templates inside my plugin if they weren’t being used from the front-end. However, if you'd like to change the default template path to your front-end template directory [this answer](https://craftcms.stackexchange.com/questions/4353/rendertemplate-in-a-plugin-for-front-end-request-using-front-end-template) will help.
  
  > **Comments:**
  > **username_0**: Thanks username_1 - have tried with plugin template paths but still getting error `Unable to find the template “emails/prospect”.`  
  > **username_1**: Need to use `craft()->templates->render( 'pluginname/templatename' );` so plugin name and then leave out your templates directory. I've updated my original answer.  
  > **username_0**: Thanks username_1! Fixed by updating template path:       `$path = craft()->path->getSiteTemplatesPath();`      `craft()->path->setTemplatesPath($path);`  
  
  ---
  
  