diff --git a/FirstStep/Services/EmailSevices/EmailService.cs b/FirstStep/Services/EmailSevices/EmailService.cs index 7e78c8a5..b8dead65 100644 --- a/FirstStep/Services/EmailSevices/EmailService.cs +++ b/FirstStep/Services/EmailSevices/EmailService.cs @@ -3,9 +3,10 @@ using FirstStep.Data; using FirstStep.Models; using FirstStep.Models.DTOs; +using FirstStep.Template; using Microsoft.EntityFrameworkCore; using MimeKit; -using System.Threading; +using System.Resources; namespace FirstStep.Services { @@ -107,11 +108,7 @@ public async Task SendOTPEmail(VerifyEmailDto request) //Send OTP to the { var builder = new BodyBuilder(); - using (StreamReader SourceReader = File.OpenText("././Template/CommonOTPEmailTemplate.html")) - { - builder.HtmlBody = SourceReader.ReadToEnd(); - } - + builder.HtmlBody = EmailTemplates.CommonOTP; otpBody.To = request.email; otpBody.Subject = "FirstStep Verification OTP"; builder.HtmlBody = builder.HtmlBody.Replace("{OTP}", OTPrequest.otp.ToString()); diff --git a/FirstStep/Template/EmailTemplates.cs b/FirstStep/Template/EmailTemplates.cs new file mode 100644 index 00000000..c6952f29 --- /dev/null +++ b/FirstStep/Template/EmailTemplates.cs @@ -0,0 +1,49 @@ +namespace FirstStep.Template +{ + public static class EmailTemplates + { + public static string CommonOTP = + @" + + + + + Verify Your Email + + +
+

FirstStep

+

Hello {name}!

+

Verify your Email

+

Below is your one-time password. Use that code to verify your email {message}.

+
+

OTP Code:

+

{OTP}

+
+

- FirstStep

+
+ + "; + + public static string ApplicationSentEmail = + @" + + + + Verify Your Email + + +
+

FirstStep

+ + +
+

Hi {username}

+

Your Application has been successfully sent.

+
+

- FirstStep

+
+ + "; + } +}