private SendGridMessage GetSendGridMessage(List <EmailInfoItem> batch, EmailAddress from, SendGridAccount sendGridAccount, EmailInfo emailInfo) { var sendGridMessage = new SendGridMessage(); sendGridMessage.SetFrom(from); if (emailInfo.TemplateData != null) { sendGridMessage.TemplateId = sendGridAccount.TemplateId; } else { sendGridMessage.SetGlobalSubject(emailInfo.Subject); if (!string.IsNullOrEmpty(emailInfo.PlainTextContent)) { sendGridMessage.AddContent(MimeType.Text, emailInfo.PlainTextContent); } if (!string.IsNullOrEmpty(emailInfo.HtmlContent)) { sendGridMessage.AddContent(MimeType.Html, emailInfo.HtmlContent); } } for (var personalizationIndex = 0; personalizationIndex < batch.Count; ++personalizationIndex) { var emailInfoItem = batch[personalizationIndex]; var to = GetEmailAddress(emailInfoItem); sendGridMessage.AddTo(to, personalizationIndex); if (emailInfo.TemplateData != null) { sendGridMessage.SetTemplateData(emailInfo.TemplateData, personalizationIndex); } if (emailInfoItem.Email != null) { sendGridMessage.AddCustomArg("EmailId", emailInfoItem.Email.Id.ToString(), personalizationIndex); } } if (emailInfo.SendAt != null) { sendGridMessage.SendAt = new DateTimeOffset(emailInfo.SendAt.Value).ToUnixTimeSeconds(); } if (emailInfo.AttachmentName != null) { sendGridMessage.AddAttachment(emailInfo.AttachmentName, emailInfo.AttachmentBase64Content); } return(sendGridMessage); }
public AccountController(UserManager <AppUser> userManager, SignInManager <AppUser> signInManager, AppDbContext context, IToastNotification toastNotification, IOptions <SendGridAccount> userOptions, IStringLocalizer <AccountController> localizer) { _context = context; _localizer = localizer; _userManager = userManager; _signInManager = signInManager; _toastNotification = toastNotification; _userOptions = userOptions.Value; }
private async Task Send(SendGridAccount sendGridAccount, SendGridMessage sendGridMessage) { var client = new SendGridClient(sendGridAccount.ApiKey); var response = await client.SendEmailAsync(sendGridMessage); if (response.StatusCode >= HttpStatusCode.Ambiguous) { var errorMessage = await GetErrorMessage(response); throw new Exception(errorMessage); } }
public SendGridWebApiClient(SendGridAccount account) { _account = account; }
internal Filters(SendGridAccount account) : base(account, "filters") { }
internal Emails(SendGridAccount account) : base(account, "lists", "email") { }
public EmailService(IOptions <SendGridAccount> account) { _account = account.Value ?? throw new ArgumentNullException(nameof(account)); }
public MarketingEmailsApiClient(SendGridAccount account) { _account = account; }
public EmailService(IOptions <SendGridAccount> account) // startuptan bıraya getiriyoruz. { _account = account.Value ?? throw new ArgumentNullException(nameof(account)); }
internal Schedule(SendGridAccount account) : base(account, "schedule") { }
internal Recipients(SendGridAccount account) : base(account, "recipients") { }
internal Identity(SendGridAccount account) : base(account, "identity") { }
public EnforcedTls(SendGridAccount account) : base(account) { }
internal SpamReports(SendGridAccount account) : base(account, "spamreports") { }
internal Credentials(SendGridAccount account) : base(account, "credentials") { }
internal Settings(SendGridAccount account) { _account = account; }
internal IpManagement(SendGridAccount account) : base(account) { }
internal TemplateEngine(SendGridAccount account) { _account = account; }
internal MarketingEmails(SendGridAccount account) : base(account) { }
internal WebApiHandler(SendGridAccount account, bool useV3) : base(new HttpClientHandler()) { _account = account; _useV3 = useV3; }
internal Unsubscribes(SendGridAccount account) : base(account, "unsubscribes") { }
internal Profile(SendGridAccount account) : base(account, "profile") { }
internal Mail(SendGridAccount account) : base(account, "mail") { }
internal ParseWebhook(SendGridAccount account) : base(account, "parse") { }
internal Bounces(SendGridAccount account) : base(account, "bounces") { }
internal AdvancedSuppressionManager(SendGridAccount account) : base(account) { }
internal Lists(SendGridAccount account) : base(account, "lists") { }
internal Blocks(SendGridAccount account) : base(account, "blocks") { }
internal Timezone(SendGridAccount account) : base(account, "timezone") { }
internal InvalidEmails(SendGridAccount account) : base(account, "invalidemails") { }
internal Categories(SendGridAccount account) : base(account, "categories") { }
internal Variations(SendGridAccount account) : base(account, "variations") { }