Example #1
0
        public void SendEmail(EmailFromType type, string toEmailAddress, string accountName, string subject, string plainTextBody, string htmlBody)
        {
            var emailFromCredentials = GetEmailCredentials(type);
            var client = new SendGridClient(emailFromCredentials.SendGridApiKey);
            var from   = new EmailAddress(emailFromCredentials.EmailAddress.Address, emailFromCredentials.Name);
            var to     = new EmailAddress(toEmailAddress, accountName);

            var msg      = MailHelper.CreateSingleEmail(from, to, subject, plainTextBody, htmlBody);
            var response = client.SendEmailAsync(msg).ConfigureAwait(true);
        }
Example #2
0
        private EmailCredentialModel GetEmailCredentials(EmailFromType type)
        {
            switch (type)
            {
            case EmailFromType.Accounts:
                return(_configurationService.GetAccountsEmailCredentials());

            default:
                throw new Exception($"{type.ToString()} is not a valid");
            }
        }