public TestForm(string pUsername, string pPassword, string pMailserver) { EmailUsername = pUsername; EmailPassword = pPassword; MailServer = pMailserver; InitializeComponent(); DefaultLogger.SetLog(new FileLogger()); FileLogger.Enabled = true; FileLogger.Verbose = true; tmrMailChecker.Enabled = true; pop3Client = new Pop3Client(); string myDocs = Environment.GetFolderPath(Environment.SpecialFolder.Personal); string file = Path.Combine(myDocs, "OpenPopLogin.txt"); if (File.Exists(file)) { using (StreamReader reader = new StreamReader(File.OpenRead(file))) { popServerTextBox.Text = reader.ReadLine(); // Hostname portTextBox.Text = reader.ReadLine(); // Port useSslCheckBox.Checked = bool.Parse(reader.ReadLine() ?? "true"); // Whether to use SSL or not loginTextBox.Text = reader.ReadLine(); // Username passwordTextBox.Text = reader.ReadLine(); // Password } } tmrMailChecker.Enabled = true; CheckTEmailRecivetimer = new System.Threading.Timer(this.CheckTEmailRecivetimerCheck, this, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(60)); }
public ScanMail_Auto() { InitializeComponent(); FillGrid_MailList(); DefaultLogger.SetLog(new FileLogger()); // Enable file logging and include verbose information FileLogger.Enabled = true; FileLogger.Verbose = true; pop3Client = new Pop3Client(); //讀取設定檔 // This is only for faster debugging purposes // We will try to load in default values for the hostname, port, ssl, username and password from a file string myDocs = Environment.GetFolderPath(Environment.SpecialFolder.Personal); string file = Path.Combine(myDocs, "OpenPopLogin.txt"); if (File.Exists(file)) { using (StreamReader reader = new StreamReader(File.OpenRead(file))) { // This describes how the OpenPOPLogin.txt file should look like popServerTextBox.Text = reader.ReadLine(); // Hostname portTextBox.Text = reader.ReadLine(); // Port useSslCheckBox.Checked = bool.Parse(reader.ReadLine() ?? "true"); // Whether to use SSL or not //loginTB.Text = reader.ReadLine(); // Username //passwordTB.Text = reader.ReadLine(); // Password } } }
public frmMain() { InitializeComponent(); POP3EraserLogger log = new POP3EraserLogger(this); DefaultLogger.SetLog(log); cmbAuthMethod.SelectedIndex = 2; currentThread = new Thread(ExecuteThread); }
/// <summary> /// Example showing: /// - How to change logging /// - How to implement your own logger /// </summary> public static void ChangeLogging() { // All logging is sent trough logger defined at DefaultLogger.Log // The logger can be changed by calling DefaultLogger.SetLog(someLogger) // By default all logging is sent to the System.Diagnostics.Trace facilities. // These are not very useful if you are not debugging // Instead, lets send logging to a file: DefaultLogger.SetLog(new FileLogger()); FileLogger.LogFile = new FileInfo("MyLoggingFile.log"); // It is also possible to implement your own logging: DefaultLogger.SetLog(new MyOwnLogger()); }
public TestForm() { // // Required for Windows Form Designer support // InitializeComponent(); DefaultLogger.SetLog(new FileLogger()); // Enable file logging and include verbose information FileLogger.Enabled = true; FileLogger.Verbose = true; pop3Client = new Pop3Client(); }
private TestForm() { // // Required for Windows Form Designer support // InitializeComponent(); // // User defined stuff here // // This is how you would override the default logger type // Here we want to log to a file DefaultLogger.SetLog(new FileLogger()); // Enable file logging and include verbose information FileLogger.Enabled = true; FileLogger.Verbose = true; pop3Client = new Pop3Client(); // This is only for faster debugging purposes // We will try to load in default values for the hostname, port, ssl, username and password from a file //string myDocs = Environment.GetFolderPath(Environment.SpecialFolder.Personal); //string file = Path.Combine(myDocs, "OpenPopLogin.txt"); //if (File.Exists(file)) //{ // using (StreamReader reader = new StreamReader(File.OpenRead(file))) // { // // // //GPC Modified to read values into variables as well as the textboxes on the form 2016-12-06 // //This describes how the OpenPOPLogin.txt file should look like // // // string popServer = reader.ReadLine(); // Hostname // popServerTextBox.Text = popServer; // string porttoUse = reader.ReadLine(); // Port // portTextBox.Text = porttoUse; // bool useSsl = bool.Parse(reader.ReadLine() ?? "true"); // Whether to use SSL or not // useSslCheckBox.Checked = useSsl; // string longinID = reader.ReadLine(); // Username // loginTextBox.Text = longinID; // string password = reader.ReadLine(); // Password // passwordTextBox.Text = password; // } //} }
private TestForm() { // // Required for Windows Form Designer support // InitializeComponent(); // // User defined stuff here // // This is how you would override the default logger type // Here we want to log to a file DefaultLogger.SetLog(new FileLogger()); // Enable file logging and include verbose information FileLogger.Enabled = true; FileLogger.Verbose = true; pop3Client = new Pop3Client(); // This is only for faster debugging purposes // We will try to load in default values for the hostname, port, ssl, username and password from a file string myDocs = Environment.GetFolderPath(Environment.SpecialFolder.Personal); string file = Path.Combine(myDocs, "BestCS.OpenPopLogin.txt"); if (File.Exists(file)) { using (StreamReader reader = new StreamReader(File.OpenRead(file))) { // This describes how the OpenPOPLogin.txt file should look like popServerTextBox.Text = reader.ReadLine(); // Hostname portTextBox.Text = reader.ReadLine(); // Port useSslCheckBox.Checked = bool.Parse(reader.ReadLine() ?? "true"); // Whether to use SSL or not loginTextBox.Text = reader.ReadLine(); // Username passwordTextBox.Text = reader.ReadLine(); // Password } } }
/// <summary> /// Return last mail's content stored in the database /// </summary> /// <param name="MailServerName">EMail server name</param> /// <param name="PortNo">EMail port no</param> /// <param name="isSslEnabled">Is SSL enabled</param> /// <param name="loginName">EMail Id for which you want ot get the data</param> /// <param name="Password">EMail password</param> /// <returns>Currently return last mail's data</returns> public DataTable mailcontents(string MailServerName, int PortNo, bool isSslEnabled, string loginName, string Password) { Dictionary <int, Message> messages = new Dictionary <int, Message>(); DataTable datatable = new DataTable(); //// This is how you would override the default logger type //// Here we want to log to a file DefaultLogger.SetLog(new FileLogger()); FileLogger.LogPath = HttpContext.Current.Server.MapPath("~/Attachments/"); // Enable file logging and include verbose information FileLogger.Enabled = true; FileLogger.Verbose = true; try { pop3Client = new Pop3Client(); data = new Pop3DataClient(); if (pop3Client.Connected) { pop3Client.Disconnect(); } pop3Client.Connect(MailServerName, PortNo, isSslEnabled); pop3Client.Authenticate(loginName, Password); //DateTime? lastmsgSavedDate = data.GetLastSavedDate(ConnString, loginName); //messages = pop3Client.GetAllMessages(lastmsgSavedDate); //Used to get all messages from the given EMail Id //foreach (Message message in messages.Values) //{ int msgcount = pop3Client.GetMessageCount(); Message message = pop3Client.GetMessage(msgcount); data.SaveMessageToDatabase(ConnString, message, FileLogger.LogPath); //} //Currently return last inserted data datatable = data.GetMessageFromDatabase(ConnString).Tables[0]; return(datatable); } catch (InvalidLoginException) { DefaultLogger.Log.LogError("POP3 Server Authentication: The server did not accept the user credentials!"); return(datatable); } catch (PopServerNotFoundException) { DefaultLogger.Log.LogError("POP3 Retrieval: The server could not be found"); return(datatable); } catch (PopServerLockedException) { DefaultLogger.Log.LogError("POP3 Account Locked: The mailbox is locked. It might be in use or under maintenance. Are you connected elsewhere?"); return(datatable); } catch (LoginDelayException) { DefaultLogger.Log.LogError("POP3 Account Login Delay: Login not allowed. Server enforces delay between logins. Have you connected recently?"); return(datatable); } catch (Exception ex) { DefaultLogger.Log.LogError("Failed Code due to: " + ex.Message + "\r\n" + "Stack trace:\r\n" + ex.StackTrace); return(datatable); } }