예제 #1
0
파일: Program.cs 프로젝트: gavioto/evimsync
        static void Main(string[] args)
        {
            IMAPConfig config = new IMAPConfig("imap.gmail.com", "atmospherian", "Xr3pr1s3Y", true, true, "");
            config.SaveConfig(@"c:\settings.cfg");
            //IMAPConfig config = new IMAPConfig(@"c:\test1.cfg");
            IMAPAsyncClient client = new IMAPAsyncClient(config, 5);

            client.MailboxManager.CreateNewMailbox(@"c:\test.mbx");

            client.Start();
            FolderTreeRequest ftr = new FolderTreeRequest("\"\"", null);
            client.RequestManager.SubmitAndWait(ftr,false);

            IBatchRequest batch = new SimpleBatchRequest();
            foreach (IFolder folder in client.MailboxManager.GetAllFolders())
            {
                FolderDataRequest fdr = new FolderDataRequest(folder, null);
                fdr.RequestCompleted += delegate(IRequest req)
                                            {
                                                FolderDataProcessor fdp = req.GetProcessorAsType<FolderDataProcessor>();
                                                IFolder f = fdp.Request.Command.ParameterObjects[0] as IFolder;
                                                Console.WriteLine("Data for {0} loaded. {1} Messages found.", f.Name, f.Exists);
                                            };
                batch.Requests.Add(fdr);
            }

            client.RequestManager.SubmitBatchAndWait(batch, false);
            batch.Requests.Clear();
            foreach (IFolder folder in client.MailboxManager.GetAllFolders())
            {
                MessageListRequest mlr = new MessageListRequest(folder, null);
                mlr.RequestCompleted += delegate(IRequest req)
                                            {
                                                MessageListProcessor fdp = req.GetProcessorAsType<MessageListProcessor>();
                                                IFolder f = fdp.Request.Command.ParameterObjects[0] as IFolder;
                                                Console.WriteLine("Message List for {0} loaded. {1} Messages found.", f.Name, f.Exists);
                                            };

                batch.Requests.Add(mlr);
            }

            client.RequestManager.SubmitBatchAndWait(batch, false);

            client.MailboxManager.DownloadEntireAccount(delegate(int messagesCompleted, int totalMessages, IFolder currentFolder)
                                                            {
                                                                Console.WriteLine();
                                                                Console.WriteLine("Message {0} of {1} downloaded from {2}", messagesCompleted, totalMessages, currentFolder.Name);
                                                            }, delegate(int totalFolders, int totalMessages, long totalTime)
                                                                   {
                                                                       Console.WriteLine("{0} Messages in {1} folders downloaded in {2} minutes.", totalMessages, totalFolders, new TimeSpan(totalTime).Minutes);
                                                                   });

            //config.CacheFi

            Console.WriteLine("Press any key");
            Console.ReadLine();

            client.Stop();
        }
예제 #2
0
파일: Form1.cs 프로젝트: gavioto/evimsync
 private void button1_Click(object sender, EventArgs e)
 {
     label1.Text = "Getting folder list...";
     IMAPConfig config = new IMAPConfig(@"c:\test1.cfg");
     client = new IMAPAsyncClient(config, 5);
     //IMAPConnectionPool.GetInstance().StartUp(config, 5);
     client.Start();
     client.RequestManager.SubmitRequest(new FolderTreeRequest("\"\"", FolderTreeCallback), false);
     button1.Enabled = false;
     button2.Enabled = true;
 }
예제 #3
0
파일: MainFrm.cs 프로젝트: gavioto/evimsync
        private List<Note> GetMailList(string server, string username, string password, string notefolder)
        {
            List<Note> noteList = new List<Note>();
            if (cancelled)
            {
                return noteList;
            }

            IMAPConfig config = new IMAPConfig(server, username, password, true, true, "/");
            client = new IMAPAsyncClient(config, 2);
            if (client.Start(false) == false)
            {
                cancelled = true;
                return noteList;
            }

            GetMailsListRecursive(notefolder, ref noteList);

            return noteList;
        }