I want to use email template with SingleEmailMessage for composing email. For one object I may send a few emails with different values in it. Email Template should be smth like this:
Hello {!Opportunity.LastModifiedBy},
Please take a <a href="surveyUrl">survey</a>.
The thing is that I want to generate surveyUrl in code for the same object and then send those different emails.
For example, for each Contact of Opportunity I want to send different emails for those Contacts. Template is the same, but value of surveyUrl variable is different.
At first, I wanted to use
email.setTemplateId(emailTemplateId);
email.setTargetObjectId(oppIdItem);
but this don't allow me to set unique value of surveyUrl variable for all emails.
Is there any way I can use template and put object into email, but not it's id?