Witam,
Mam problem próbuje pobrać emaila z informacją od kogo do kogo i treścią nie ma problemu ale w jaki sposób pobrać treść emaila. Poniżej jak to robię teraz:
static void Main(string[] args)
{
string response;
int totmessages;
string msg;
TcpClient mailclient;
SslStream NetStrm;
StreamReader sr;
StreamWriter sw;
NetworkStream ns;
string attachment;
string filename;
string[] data;
int startindex;
int index;
int lastindex;
string x;
MemoryStream ms;
FileStream fs;
try {
mailclient = new TcpClient("adres_serwera_poczty", Convert.ToInt16("995"));
}
catch (SocketException)
{
Console.WriteLine("Unable to connect to server 1");
return;
}
if (true)
{
NetStrm = new SslStream(mailclient.GetStream());
NetStrm.AuthenticateAsClient("adres_serwera_poczty");
sr = new StreamReader(NetStrm);
sw = new StreamWriter(NetStrm);
}
else
{
ns = mailclient.GetStream();
sr = new StreamReader(ns);
sw = new StreamWriter(ns);
}
response = sr.ReadLine(); //Get opening POP3 banner
sw.WriteLine("user " + "=====@====.pl"); //Send username
sw.Flush();
response = sr.ReadLine();
if (response.Substring(0, 3) == "-ER") //0,4) == "-ERR"
{
Console.WriteLine("Unable to log into server 2");
return;
}
sw.WriteLine("pass " + "====="); //Send password
sw.Flush();
response = sr.ReadLine();
if (response.Substring(0, 3) == "-ER")
{
Console.WriteLine("Unable to log into server 3");
return;
}
sw.WriteLine("stat"); //Send stat command to get number of messages
sw.Flush();
response = sr.ReadLine();
//find number of message
string[] nummess = response.Split(' ');
totmessages = Convert.ToInt16(nummess[1]);
//read emails
for (int i = 947; i <= 947; i++) //for (int i = 1; i <= totmessages; i++) //947 bo tyle mam emaili w skrzynce a chce odczytac 1
{
msg = null;
sw.WriteLine("top " + i + " 0"); //read header of each message
sw.Flush();
response = sr.ReadLine();
//Console.Clear();
//Console.WriteLine("Numer widomosci przetworzonej {0}", i);
string[] nummessaaa = null;
while (true)
{
response = sr.ReadLine();
if (response == ".")
break;
msg = msg + response + "\r\n";
nummessaaa = msg.Split('\n');
}
foreach (var item in nummessaaa)
{
Console.WriteLine(item);
}
}
sw.WriteLine("quit"); //quit
sw.Flush();
}
W załączniku co dostaje, jak widać nie ma treści i nie wiem jak ją odczytać. ma ktoś może jakieś pomysły
Pozdrawiam