public static MailAddress GetFrom(this INotificationsSettings config, IEmailRecipientSettings recipients) { if (config == null) { throw new ArgumentNullException(nameof(config)); } if (recipients == null) { throw new ArgumentNullException(nameof(recipients)); } try { return(config.SystemEmails.GetByToken(recipients.FromToken).BuildMailAddress()); } catch (ArgumentOutOfRangeException ex) { throw new InvalidOperationException($"GetFrom failed for {recipients.Token} email", ex); } }
public static IEnumerable <MailAddress> GetBcc(this INotificationsSettings config, IEmailRecipientSettings recipients) { if (config == null) { throw new ArgumentNullException(nameof(config)); } if (recipients == null) { throw new ArgumentNullException(nameof(recipients)); } try { return(recipients.BccTokens.Select(token => config.SystemEmails.GetByToken(token)).Select(x => x.BuildMailAddress())); } catch (ArgumentOutOfRangeException ex) { throw new InvalidOperationException($"GetBcc failed for {recipients.Token} email", ex); } }