示例#1
0
        public Task <Response> SendEmailAsync(string email, string templateID, string from, IEmailTemplateData dynamicTemplateData)
        {
            var client = new SendGridClient(Options.ApiKey);
            var msg    = new SendGridMessage();

            msg.SetFrom(new EmailAddress(from));
            msg.SetTemplateId(templateID);
            msg.AddTo(new EmailAddress(email));
            msg.SetTemplateData(dynamicTemplateData);
            msg.SetClickTracking(false, false);

            return(client.SendEmailAsync(msg));
        }
示例#2
0
 public Task <Response> SendEmailAsync(string email, string templateID, string from, IEmailTemplateData dynamicTemplateData)
 {
     _logger.LogInformation($"To: {email} TemplateID: {templateID} From: {from} Data: {(dynamicTemplateData != null ? dynamicTemplateData.ToString() : "No Data")}");
     return(Task.Run(() => new Response(System.Net.HttpStatusCode.Accepted, null, null)));
 }
示例#3
0
        public Task <Response> SendEmailAsync(string email, string templateID, EmailFrom from, IEmailTemplateData dynamicTemplateData)
        {
            var fromEmail = "@coronaverdict.com";

            switch (from)
            {
            case EmailFrom.Account:
            {
                fromEmail = "account" + fromEmail;
                break;
            }

            case EmailFrom.Admin:
            {
                fromEmail = "admin" + fromEmail;
                break;
            }

            case EmailFrom.Contact:
            {
                fromEmail = "contact" + fromEmail;
                break;
            }

            case EmailFrom.Report:
            {
                fromEmail = "report" + fromEmail;
                break;
            }

            default:
            {
                fromEmail = "support" + fromEmail;
                break;
            }
            }

            var client = new SendGridClient(Options.ApiKey);
            var msg    = new SendGridMessage();

            msg.SetFrom(new EmailAddress(fromEmail, "CoronaVerdict"));
            msg.SetTemplateId(templateID);
            msg.AddTo(new EmailAddress(email));
            msg.SetTemplateData(dynamicTemplateData);
            msg.SetClickTracking(false, false);

            return(client.SendEmailAsync(msg));
        }