Esempio n. 1
0
        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);
            }
        }
Esempio n. 2
0
        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);
            }
        }