Witam
pisze taki maly program wylacznie do odberania wiadomosci e-mail i mam taki maly propblem ....
mianowicie po polaczeniu z poczta program widzi ze jest 5 wiadomosci , wysylam z innego konta pocztowego na ten adres email jakas wiadomosc test i jest juz na tamtym koncie 6 wiadomosci , jednak moja aplikacja nadal widzi tylko 5 .... dopiero po rozlaczeniu i ponownym polaczeniu z kontem pocztowym jest widoczne 6 wiadomosci ...
troche namieszalem w pytaniu ale mam nadzieje zemnie zrozumiecie :)
ponizej klasaktora wykorzystuje w programie
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Sockets;
using System.Net.Security;
using System.IO;
namespace Test_POP3
{
class Mail
{
public TcpClient client;
public SslStream stream;
public StreamReader reader;
public string login(string server, int port, string user, string password)
{
client = new TcpClient();
client.Connect(server, 995);
stream = new SslStream(client.GetStream(), false);
stream.AuthenticateAsClient(server);
reader = new StreamReader(stream);
string response = reader.ReadLine();
string read;
read = send("USER " + user);
if (read.StartsWith("+OK") == false) return (read);
read = send("PASS " + password);
if (read.StartsWith("+OK") == false) return (read);
return (read);
}
public string send(string text)
{
try
{
byte[] bcmd = Encoding.ASCII.GetBytes(text + "\r\n");
stream.Write(bcmd, 0, bcmd.Length);
return reader.ReadLine();
}
catch (Exception err)
{
return ("-ERR1 " + err.ToString());
}
}
public string getText(string text)
{
StringBuilder gettext = new StringBuilder();
try
{
string read = send(text);
if (read.IndexOf("+OK") != -1)
{
do
{
gettext.Append(read + "\r\n");
read = reader.ReadLine();
} while (read != ".");
}
else
{
return read;
}
}
catch (Exception err)
{
return ("-ERR " + err.ToString());
}
return gettext.ToString();
}
public string getMail(int number)
{
return getText("RETR " + number + " ");
}
public string Rset()
{
return send("RSET");
}
public string getStat()
{
return send("STAT");
}
public string Dele(int num)
{
return send("DELE " + num + " ");
}
public string GetNoop()
{
return send("NOOP");
}
public string getList()
{
return send("LIST");
}
public string Quit()
{
if (stream == null || reader == null)
{
return ("-ERR no connection");
}
string tmp = send("QUIT"); ;
stream.Close();
reader.Close();
return tmp;
}
}
}
pozdrawiam
Andrzej Pierz