private void button1_Click(object sender, EventArgs e) { //Create a POP3 client Pop3Client pop = new Pop3Client(); //Set host, username, password etc. for the client pop.Host = "pop.chemitec.it"; pop.Username = "******"; pop.Password = "******"; pop.Port = 995; pop.EnableSsl = true; //Connect the server pop.Connect(); //Get the first message by its sequence number Pop3MessageInfoCollection m = pop.GetAllMessages(); MailMessage message = pop.GetMessage(54); //Parse the message message.Save("Sample.msg", MailMessageFormat.Msg); Console.WriteLine("------------------ HEADERS ---------------"); Console.WriteLine("From : " + message.From.ToString()); Console.WriteLine("To : " + message.To.ToString()); Console.WriteLine("Date : " + message.Date.ToString(CultureInfo.InvariantCulture)); Console.WriteLine("Subject: " + message.Subject); Console.WriteLine("------------------- BODY -----------------"); Console.WriteLine(message.BodyText); Console.WriteLine("------------------- END ------------------"); //Save the message to disk using its subject as file name message.Save(message.Subject + ".eml", MailMessageFormat.Eml); Console.WriteLine("Message Saved."); }
private void btnRun_Click(object sender, EventArgs e) { // Create a POP3 client Pop3Client client = new Pop3Client(); client.Host = this.HostInput.Text; client.Username = this.Username.Text; client.Password = this.Password.Text; client.Port = int.Parse(this.PortInput.Text); client.EnableSsl = true; client.Connect(); Pop3MessageInfoCollection msgs = client.GetAllMessages(); for (int i = 0; i < msgs.Count; i++) { MessageBox.Show(string.Format("SequenceNumber:{0};Size:{1};UniqueId:{2}", msgs[i].SequenceNumber, msgs[i].Size, msgs[i].UniqueId)); } }