Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Net.Sockets;
- using System.IO;
- using System.Collections.Generic;
- using System.Net;
- using System;
- namespace TcpPOP3Test {
- public class Program {
- public string server = "pop.kahosl.be";
- public string user = "";//mijne username
- public string pass = "";//mijne pass
- public const int POORT = 110;
- public Program() {
- string str = string.Empty;
- string strTemp = string.Empty;
- using(TcpClient tc = new TcpClient()) {
- tc.Connect(this.server,POORT);
- using(NetworkStream nws = tc.GetStream()) {
- using(StreamReader sr = new StreamReader(nws)) {
- using(StreamWriter sw = new StreamWriter(nws)) {
- sw.WriteLine("USER " + user);
- sw.Flush();
- sw.WriteLine("PASS " + pass);
- sw.Flush();
- List<string> bericht = new List<string>();
- try {
- sw.WriteLine("RETR 1");
- sw.Flush();
- if(sr.ReadLine().StartsWith("+OK")) {
- while(sr.Peek() != '.') {
- bericht.Add(sr.ReadLine());
- }
- }
- foreach(string s in bericht) {
- Console.WriteLine(s);
- }
- } catch(Exception e) {
- //fout weergeven
- Console.WriteLine("Fout in LeesBericht van IO_MailIn: {0}",e.Message);
- System.Diagnostics.Debug.WriteLine("Fout in LeesBericht van IO_MailIn: {0}",e.Message);
- //fout doorgooien
- throw e;
- }
- sw.WriteLine("QUIT");
- sw.Flush();
- }
- }
- }
- }
- }
- public static void Main(string[] args) {
- Program p = new Program();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement