示例#1
0
        private void MessageListComplete(IRequest req)
        {
            MessageListProcessor mlp = req.GetProcessorAsType <MessageListProcessor>();

            //mlp.Request.Command.
            //textBox1.Invoke(new UpdateTextCallback(UpdateTextBox), new object[] {mlp.CmdResult.Results});
            UpdateTextBox(mlp.CmdResult.Results);
            UpdateMessageList(mlp.UIDs);
            UpdateLabel("");
        }
示例#2
0
文件: DeskScop.cs 项目: afit/DeskScop
        // FIXME fix datagrid action alias
        // FIXME inform user how many messages were record or processed
        // FIXME preview mode
        // FIXME status bar on bad auth
        // FIXME search
        // FIXME updating multiple
        /// <exception cref="System.Configuration.ConfigurationException">Thrown when application configuration is absent.</exception>
        protected DeskScop()
        {
            if( ConfigurationManager.AppSettings.Count == 0 ) {
                MessageBox.Show(
                    "DeskScop couldn't start as it is missing its configuration file. Check that the DeskScop.exe.config file is in the same folder as the DeskScop executable.",
                    "DeskScop is misconfigured",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error
                );
                throw new ConfigurationErrorsException( "Couldn't find configuration." );
            }

            // Get empty constructor for message list processor class.
            mProcessor = (MessageListProcessor) Activator.CreateInstance(
                null, ConfigurationManager.AppSettings[ "messageListProcessor" ]
            ).Unwrap();
        }
示例#3
0
        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();
        }