EmailSetupNewPassword.cs 1.25 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;

namespace MEU.API.Services.Emails.Templates
{
    public class EmailSetupNewPassword: EmailContent
    {
        protected string _Link = "";
        protected string _Username = "";

        public EmailSetupNewPassword(string EmailSubject, string Link, string Username, string RecieverUser)
        {
            this.EmailTemplatePath += "/EmailSetupNewPassword.html";
            _Link = Link;
            _Username = Username;
            this.Reciever = RecieverUser;
            this.Subject = EmailSubject;
        }

        public override string GetContent()
        {
            string fullBody =  File.ReadAllText(this.EmailTemplatePath);
            fullBody = fullBody.Replace("{{link}}", this._Link);
            fullBody = fullBody.Replace("{{username}}", this.Reciever);
            return fullBody;
        }

        public override bool Send()
        {
             this.SendEmail(this.Reciever, this.Subject, this.GetContent());
            return true;
        }

        public override async Task SendAsync()
        {
            await Task.Run(() => this.SendEmailAsync(this.Reciever, this.Subject, this.GetContent()));
        }
    }
}