function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
PS81PS81 

Visualforce email template : "send Test..." hitting error "The template does not have a controller that can be selected for preview."

Hi

I have created a simple visualforce email template to be used in my apex class (note the email to be triggered from apex and not via any user action via vf page).
 
<messaging:emailTemplate subject="<i>Your campaign {!relatedTo.Name} is due to start.</i>" recipientType="user" relatedToType="Campaign">
<messaging:htmlEmailBody >
<html>
    Dear {!recipient.name}<br></br>
    <br>
    Notification that "{!relatedTo.Name}" is due to start today. 
    </br>
</html>
</messaging:htmlEmailBody>
</messaging:emailTemplate>

But when i wanted to test it via the "Send Test and Verify Merge Fields" i do not get to see any selection but rather a message 

The template does not have a controller that can be selected for preview.

Any input on where i'm going wrong and what needs to be done here please?


 
Best Answer chosen by PS81
James LoghryJames Loghry
Kind of a crummy error.  Try capitalizing User in your recipient type for one.  Also, make sure that when you pass in the test data, you're selecting a User record for the recipient rather than a Contact record, as that may confuse your template.

All Answers

James LoghryJames Loghry
Kind of a crummy error.  Try capitalizing User in your recipient type for one.  Also, make sure that when you pass in the test data, you're selecting a User record for the recipient rather than a Contact record, as that may confuse your template.
This was selected as the best answer
PS81PS81
deleted and re-created it...works fine now. thanks!