Add attachment template. Revise email encode function.