Exemplo n.º 1
0
        Brush GetColourAndStatus(string account1, string account1Displayname)
        {
            Brush colour;

            if (string.IsNullOrEmpty(account1) && string.IsNullOrEmpty(account1Displayname))
            {
                colour = Brushes.Gray;
            }
            else if (!string.IsNullOrEmpty(account1) || !string.IsNullOrEmpty(account1Displayname))
            {
                if (OutlookSearch.IsValidEmail(account1) && !string.IsNullOrEmpty(account1Displayname))
                {
                    colour = Brushes.Green;
                }
                else
                {
                    colour = Brushes.Red;
                }
            }
            else
            {
                colour = Brushes.Red;
            }

            return(colour);
        }
        public void Add(string AccountField)
        {
            try
            {
                if (OutlookSearch.IsAccountValid(AccountField))
                {
                    var account = new AccountConfig()
                    {
                        EmailAddress = AccountField,
                        IsConfigured = true
                    };

                    if (account != null)
                    {
                        Accounts.Add(account);
                    }
                }
                else
                {
                    MessageBox.Show("Failed to add account");
                }
            }
            catch (Exception ex)
            {
                Logger.Log($"Error {ex.Message}");
            }
        }
Exemplo n.º 3
0
        public SentMailViewModel(string email)
        {
            Account = new OutlookSearch()
            {
                EmailAddress = email
            };
            Account.OnSearchComplete += EmailSearchComplete;

            _statusTimer = new System.Timers.Timer(200)
            {
                AutoReset = true
            };
            _statusTimer.Elapsed += UITimerElapsed;
            _statusTimer.Start();

            _account.OnSearchErrorOccurred += OutlookErrorOccurred;

            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
        }
        public EmailListViewModel(AccountConfig account)
        {
            if (account != null)
            {
                Account = new OutlookSearch(account);
                Account.OnSearchComplete += EmailSearchComplete;

                _statusTimer = new System.Timers.Timer(1000)
                {
                    AutoReset = true
                };
                _statusTimer.Elapsed += UITimerElapsed;
                _statusTimer.Start();

                DisplayIndex = account.DisplayIndex;
                DisplayName  = account.DisplayName;

                _account.OnSearchErrorOccurred             += OutlookErrorOccurred;
                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            }
        }
        bool CheckConfig(out string error)
        {
            var  errorBuilder = new StringBuilder();
            bool success      = false;

            List <int> indexes = new List <int>();

            foreach (var account in Accounts)
            {
                if (indexes.Contains(account.DisplayIndex))
                {
                    success = false;
                    errorBuilder.AppendLine(account.EmailAddress + " index is not unique");
                }
                else
                {
                    indexes.Add(account.DisplayIndex);
                    success = true;
                }

                if (account.SearchTag == "Enter a search tag")
                {
                    success = false;
                    errorBuilder.AppendLine(account.EmailAddress + " search tag is at default value");
                }

                if (!OutlookSearch.IsAccountValid(account.EmailAddress))
                {
                    success = false;
                    errorBuilder.AppendLine(account.EmailAddress + " is not configured in outlook. The account needs to be configured with full read/write access.");
                }
            }

            error = errorBuilder.ToString();

            return(success);
        }
 public bool CanAdd()
 {
     return(OutlookSearch.IsValidEmail(AccountField) && Accounts.Count < 3 && Accounts.Count >= 0);
 }