How to send email from SendGrid/Twilio

I have written method like we are sending OTP in email

 //SendGrid email sender
        public async Task SendOTPByEmail(string otp, string toEmail,string toName)
            var client = new SendGridClient(YourSendGridEmailApiKey);
            var from = new EmailAddress("you sendgrid verified email", "Sender name");
            var subject = "OTP for login";
            var to = new EmailAddress(toEmail, toName);
            var plainTextContent = "OTP for login in application:" + otp;
            var htmlContent = "<strong>An OTP for login:</strong>" +otp;
            var msg = MailHelper.CreateSingleEmail(from, to, subject, plainTextContent, htmlContent);
            var response = await client.SendEmailAsync(msg);
Posted in: C#

Leave a Reply

Your email address will not be published. Required fields are marked *