Beispiel #1
0
        static void Main(string[] args)
        {
            var config             = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            var imapServiceSection = new ImapService();

            imapServiceSection.Hostname = "default";
            imapServiceSection.Port     = 993;

            config.Sections.Add("imapService", imapServiceSection);

            var credentialsSection = new Credentials();

            credentialsSection.Username = "******";
            credentialsSection.Password = "";
            config.Sections.Add("credentials", credentialsSection);

            var filesystemExportSection = new FileSystemExport();

            filesystemExportSection.ExportDirectory = "";
            config.Sections.Add("fileSystemExport", filesystemExportSection);

            var imapFoldersSection = new ImapFolders();

            imapFoldersSection.SourceFolder    = "/";
            imapFoldersSection.ProcessedFolder = "PROCESSED";
            imapFoldersSection.AttentionFolder = "ATTENTION";
            config.Sections.Add("imapFolders", imapFoldersSection);

            config.Save(ConfigurationSaveMode.Full);
        }
Beispiel #2
0
        private InvoiceDownloader(
            ImapService serviceConfig,
            Credentials credentials,
            string folder,
            AttachmentProcessor attachmentProcessor)
        {
            imapService      = new SimpleImapService(serviceConfig, credentials);
            sourceFolderName = folder;
            mailFolderFinder = new MailFolderFinder(
                client => folderName => client
                .GetFolder(client.PersonalNamespaces[0])
                .GetSubfolders(false)
                .Where(subFolder => subFolder.Name.ToUpper().Equals(folderName.ToUpper())),
                imapService.client
                );

            this.attachmentProcessor = attachmentProcessor;
        }
Beispiel #3
0
        TimesheetProcessor(
            ImapService serviceConfig,
            Credentials credentials,
            string sourceFolder, string processedFolder, string attentionFolder,
            AttachmentProcessor attachmentProcessor)
        {
            imapService         = new SimpleImapService(serviceConfig, credentials);
            sourceFolderName    = sourceFolder;
            processedFolderName = processedFolder;
            attentionFolderName = attentionFolder;
            mailFolderFinder    = new MailFolderFinder(
                client => folderName =>
            {
                var folders = new List <IMailFolder>();
                folders.Add(client.GetFolder(folderName));
                return(folders);
            },
                imapService.client
                );

            this.attachmentProcessor = attachmentProcessor;
        }
Beispiel #4
0
        private async Task OnLogin(string password)
        {
            // TODO check if username and password has been filled
            string email = Email;

            // TODO only for quick test
            if (string.IsNullOrWhiteSpace(email) && string.IsNullOrWhiteSpace(password))
            {
                try
                {
                    var lines = System.IO.File.ReadAllLines(System.IO.Path.Combine(
                                                                new System.IO.DirectoryInfo(Environment.CurrentDirectory).Parent.Parent.Parent.FullName,
                                                                "super-secret-folder\\credentials.properties"));
                    foreach (var line in lines)
                    {
                        var splits = line.Split('=');
                        switch (splits[0].ToLower())
                        {
                        case "email":
                            email = splits[1];
                            break;

                        case "password":
                            password = splits[1];
                            break;

                        default:
                            break;
                        }
                    }
                }
                catch { }
            }

            var service = new ImapService();
            await service.LoginAsync(email, password);

            LoginSucceeded?.Invoke(this, new MailAccount(email, service));
        }
Beispiel #5
0
 public MailAccount(string email, ImapService service)
 {
     Email       = email;
     _service    = SafetyChecker.RequireArgumentNonNull(service, "service");
     FoldersTask = new ObservableTask <ObservableCollection <MailFolder> >(GetFolders());
 }
 public SimpleImapService(ImapService imapService, Credentials credentials)
 {
     client           = new ImapClient();
     serviceConfig    = imapService;
     this.credentials = credentials;
 }
Beispiel #7
0
 public EmailService()
 {
     imapService = new ImapService();
     pop3Service = new POP3Service();
 }
 public YandexTaxiDataAnalyzerCore(ImapService imapService, HtmlParserService htmlParserService)
 {
     _imapService       = imapService;
     _htmlParserService = htmlParserService;
 }