private void EmailUser(string pin, string errorMsg = "") { var userId = _textFile.GetUserIdFromPin(pin); _password.UserId = userId; var credentials = _password.GetRecords() .Where(x => x.Name.ToLower() == "google" && x.Username.Contains("epym7pfs")) .ToDictionary(x => x.Username, x => x.Password) .FirstOrDefault(); var emailTable = _connector.ConfigDictionary.FirstOrDefault(x => x.Key.Contains("EmailAccount")).Value; var accTable = _connector.ConfigDictionary.FirstOrDefault(x => x.Key.Contains("UserAccount")).Value; var query = $"Select Email From {emailTable} Join {accTable} on {emailTable}.UserId = {accTable}.UserId " + $"Where {emailTable}.UserId = {userId}"; var cmd = new SqlCommand(query, _connector.GetConnectionObject()); var email = _connector.ExecuteSqlScalarStatement(cmd).ToString(); SendEmail(email, credentials, errorMsg); }