public IList <ContactIdentifier> GetContacts(SendEmailExtendedData data, FormSubmitContext formSubmitContext)
 {
     if (string.IsNullOrEmpty(data.FixedEmailAddress))
     {
         logger.LogWarn("To address is empty");
         return(new List <ContactIdentifier>());
     }
     return(data.FixedEmailAddress.Split(';').Where(x => !string.IsNullOrEmpty(x)).Select(GetContactIdentifier).ToList());
 }
        public IList <ContactIdentifier> GetContacts(SendEmailExtendedData data, FormSubmitContext formSubmitContext)
        {
            var contactIdentifier = GetContactIdentifier();

            if (contactIdentifier == null)
            {
                logger.LogWarn("Could not find identified contact.");
                return(new List <ContactIdentifier>());
            }
            return(new List <ContactIdentifier> {
                contactIdentifier
            });
        }
        public IList <ContactIdentifier> GetContacts(SendEmailExtendedData data, FormSubmitContext formSubmitContext)
        {
            var field = GetFieldById(data.FieldEmailAddressId.Value, formSubmitContext.Fields);

            if (field is null)
            {
                logger.LogWarn($"Could not find field with id {data.FieldEmailAddressId}");
            }
            var toAddresses = GetValue(field);

            if (string.IsNullOrEmpty(toAddresses))
            {
                logger.LogWarn("To address from field is empty");
                return(new List <ContactIdentifier>());
            }
            return(toAddresses.Split(';').Select(x => GetOrCreateContact(x, data.UpdateCurrentContact)).ToList());
        }
        public IList <ContactIdentifier> GetContacts(SendEmailExtendedData data, FormSubmitContext formSubmitContext)
        {
            // ReSharper disable once PossibleInvalidOperationException
            var field = GetFieldById(data.FieldEmailAddressId.Value, formSubmitContext.Fields);

            if (field is null)
            {
                logger.LogWarn($"Could not find field with id {data.FieldEmailAddressId}");
            }
            var contacts    = new List <ContactIdentifier>();
            var toAddresses = GetValue(field, data.EmailFieldInDynamicDatasource);

            foreach (var addressStrings in toAddresses)
            {
                contacts.AddRange(addressStrings.Split(';').Select(splittedAddress => GetOrCreateContact(splittedAddress, data.UpdateCurrentContact)));
            }
            return(contacts);
        }
        public Dictionary <string, object> BuildFileAttachmentTokens(SendEmailExtendedData data, FormSubmitContext formSubmitContext)
        {
            var tokens = new Dictionary <string, object>();

            if (data.FileUploadFieldsToAttach == null)
            {
                return(tokens);
            }
            foreach (var attachmentFieldId in data.FileUploadFieldsToAttach)
            {
                var field = GetFieldById(attachmentFieldId, formSubmitContext.Fields);
                if (field is null)
                {
                    logger.LogWarn($"Could not find field with id {data.FieldEmailAddressId}");
                    continue;
                }
                if (field.Value != null)
                {
                    tokens.Add($"attachment_{attachmentFieldId}", field.Value);
                }
            }
            return(tokens);
        }