/// <summary> /// Saves the config settings to the current file /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void saveBtn_Click(object sender, EventArgs e) { if (passwordBox.Text != String.Empty) { if (passwordBox2.Text == String.Empty) { MessageBox.Show("You must verify your password before you can save.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (!passwordBox.Text.Equals(passwordBox2.Text)) { MessageBox.Show("Passwords do not match", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } if (debugMode.Checked && debugDetailBox.SelectedIndex < 1) { MessageBox.Show("Please select a detail level for the debug mode.", "Select Detail Level", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } config.SaveConfig(configFile); MessageBox.Show("Settings saved successfully.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); configChanged = false; }
/// <summary> /// Prompts the user to enter the filename of the new settings file to create /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void newConfigToolStripMenuItem_Click(object sender, EventArgs e) { SaveFileDialog diag = new SaveFileDialog(); diag.OverwritePrompt = true; if (diag.ShowDialog() == DialogResult.OK) { configFile = diag.FileName; config = new IMAPConfig(); config.SaveConfig(configFile); BindConfigInfo(); UpdateTitle(); configChanged = false; } ToggleEnabled(true); }
static void Main(string[] args) { if (args.Length < 1) { Console.WriteLine("USAGE: ConfigGenerator <configfilename>"); return; } IMAPConfig config = new IMAPConfig(); Console.WriteLine("ConfigGenerator for InterIMAP"); Console.WriteLine("Copyright (C) 2008 Jason Miesionczek"); Console.WriteLine(); Console.Write("Enter Hostname: "); string host = Console.ReadLine(); Console.WriteLine(); Console.Write("Username: "******"Password: "******"Use SSL [y/N]: "); string ssl = Console.ReadLine(); Console.WriteLine(); Console.Write("Auto Logon [y/N]: "); string logon = Console.ReadLine(); Console.WriteLine(); Console.Write("Debug Mode [y/N]: "); string debug = Console.ReadLine(); Console.WriteLine(); Console.Write("Default Folder: "); string defaultFolder = Console.ReadLine(); Console.WriteLine(); Console.Write("Local cache file: "); string cache = Console.ReadLine(); Console.WriteLine(); Console.Write("Cache Format [xml/binary]: "); string format = Console.ReadLine(); Console.WriteLine(); Console.Write("Auto Sync Cache [Y/n]: "); string sync = Console.ReadLine(); Console.WriteLine(); Console.Write("Auto Retrieve All Message UIDs [Y/n]: "); string getids = Console.ReadLine(); config.AutoLogon = logon.Equals("y") ? true : false; config.DebugMode = debug.Equals("y") ? true : false; config.DefaultFolderName = defaultFolder; config.Host = host; config.Password = password; config.UserName = username; config.UseSSL = ssl.Equals("y") ? true : false; config.CacheFile = cache; config.Format = format.Equals("xml") ? CacheFormat.XML : (format.Equals("binary") ? CacheFormat.Binary : CacheFormat.XML); config.AutoGetMsgID = getids.Equals("n") ? false : true; config.AutoSyncCache = sync.Equals("y") ? true : false; config.SaveConfig(args[0]); Console.WriteLine("{0} created successfully.", args[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(); }