I've stumbled upon a problem at the final stage of a new feature I was building (as always)
I need to pass in a custom string into a salesforce template, however there doesnt seem to be a way of doing this through the standard methods.
I'm passing in a contact ID, to email the correct user and name to personailse the email. But I need a string to be passed to the template which is completely unrelated to the contact record, and need to be dynamic. So I cant just put it in the template.
Is there a way? I know i cant pass in a custom object as it needs to be a contact, user or lead id to email a user.
Can you help?
Here is the code if you need to see it:
public static void sendSingleMail(id objId, ID templateId, string fromaddress) {
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setReplyTo(fromaddress);
mail.setTemplateId(templateId);
mail.setTargetObjectId(objId);
mail.saveAsActivity = false;
mail.setReplyTo(fromaddress);
mail.setSenderDisplayName(fromaddress);
ErrLogger.logger('Email being sent to :');
ErrLogger.logger('objId found: ' + objId);
ErrLogger.logger('templateId found: ' + templateId);
ErrLogger.logger('fromaddress found: ' + fromaddress);
Messaging.sendEmail(new Messaging.SingleEmailmessage[] {mail});
}