code pop3 en visual studio 2008
bonjour,
Je réalise une application dont l'une de ces fonctionnalité est l'envoie et la reception de mail. J'ai réussi à faire l'envoie avec le smtp. Le probléme qui se pose c'est que je trouve pas celui du pop3 , et c'est un application systéme "WindowsForm". Alors si quelqu'un peut m'aider n'hésitez pas. J'ai travaillé avec se code que j'ai trouvé en changeant le serveur et le port biensur mais il me génére une erreur comme si le pop n'existe pas dans le context actuel j'y comprend rien voilà le code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
| using System;
using System.Text;
using System.Text.RegularExpressions;
using System.Net.Sockets;
using System.IO;
namespace WindowsApplication3
{
/// <summary>
/// Summary description for Pop3.
/// </summary>
public class Pop3
{
public string USER;
public string PASS;
public string SERVER;
public int PORT;
public string dataToWrite;
public string dataRead;
public string CRLF="\r\n";
public byte []sData;
public NetworkStream nwStream;
public StreamReader strReader;
public TcpClient tcpClient;
public Pop3()
{
//
// TODO: Add constructor logic here
//
}
public Pop3(string server,string user,string password)
{
try
{
USER=user;
PASS=password;
SERVER=server;
PORT=port;
tcpClient=new TcpClient();
tcpClient.Connect(SERVER,PORT);
nwStream=tcpClient.GetStream();
strReader=new StreamReader(tcpClient.GetStream());
string h=strReader.ReadLine();
h=h;
}
catch (Exception ex)
{
}
}
public string Connect()
{
string response;
response=Write("USER "+ USER +CRLF);
if(response.Substring(0,3)!="+OK")
return response;
response=Write("PASS "+ PASS +CRLF);
if(response.Substring(0,3)!="+OK")
return response;
return "+OK";
}
public string Write(string data)
{
sData = System.Text.Encoding.ASCII.GetBytes(data.ToCharArray());
nwStream.Write(sData,0,sData.Length);
StreamReader Reader=new StreamReader(tcpClient.GetStream());
return Reader.ReadLine();
}
public string UIDL(int msgNumber)
{
string response=Write("UIDL "+msgNumber.ToString()+CRLF).Trim();
return response.Replace("+OK "+msgNumber.ToString(),"").Trim();
}
public int GetTotalMails()
{
string response=Write("STAT "+CRLF);
char []delimiters={' '};
string []splitValues=response.Split(delimiters);
return Int32.Parse(splitValues[1]);
}
}
} |
si quelqu'un a quelque chose qui ressemble à ce qu'il y'a dans se site ça serais bien aussi http://www.codeproject.com/KB/IP/win32_pop3.aspx