Added template selection to sendmail