complete create email template function