pop3收信:在vs3下调试无误的pop3收信程序



using .Net.Sockets;
using .Collections;
using .IO;
using .Net;
using ;
using .Web.Mail;

public POP3
{
POPServer;
user;
pwd;
NetworkStream ns;
StreamReader sr;

public POP3{}

public POP3( server, _user, _pwd)
{
POPServer = server;
user = _user;
pwd = _pwd;
}

private void Connect
{
TcpClient sender = TcpClient(POPServer,110);
Byte outs;
input;

try
{
ns = sender.GetStream;
sr = StreamReader(ns);

sr.ReadLine;
//Console.WriteLine(sr.ReadLine );

input = \"user \" + user + \"\\r\\n\";
outs = .Text.Encoding.ASCII.GetBytes(input.ToCharArray);
ns.Write(outs,0,outs.Length) ;
sr.ReadLine;
//Console.WriteLine(sr.ReadLine );

input = \"pass \" + pwd + \"\\r\\n\";
outs = .Text.Encoding.ASCII.GetBytes(input.ToCharArray);
ns.Write(outs,0,outs.Length) ;
sr.ReadLine;
//Console.WriteLine(sr.ReadLine );

}
catch(InvalidOperationException ioe)
{
Console.WriteLine(\"Could not connect to mail server\");
}
}

private void Disconnect
{
input = \"quit\" + \"\\r\\n\";
Byte outs = .Text.Encoding.ASCII.GetBytes(input.ToCharArray);
ns.Write(outs,0,outs.Length);
//Console.WriteLine(sr.ReadLine );
ns.Close;
}

public GetNumberOfNewMessages
{
Byte outs;
input;

try
{
Connect;

input = \"stat\" + \"\\r\\n\";
outs = .Text.Encoding.ASCII.GetBytes(input.ToCharArray);
ns.Write(outs,0,outs.Length);
resp = sr.ReadLine;
//Console.WriteLine(resp);
tokens = resp.Split( Char {\' \'});

Disconnect;

Convert.ToInt32(tokens[1]);
}


catch(InvalidOperationException ioe)
{
Console.WriteLine(\"Could not connect to mail server\");
0;
}
}
public ArrayList GetNewMessages( subj)
{

count;
ArrayList msgs = ArrayList;

try
{
count = GetNumberOfNewMessages;
Connect;

for( n=1; n<count+1; n)
{
ArrayList msglines = GetRawMessage(n);
msgsubj = GetMessageSubject(msglines);
(msgsubj.CompareTo(subj) 0)
{
.Web.Mail.MailMessage msg = MailMessage;
msg.Subject = msgsubj;
msg.From = GetMessageFrom(msglines);
msg.Body = GetMessageBody(msglines);
msgs.Add(msg);
DeleteMessage(n);
&
Tags:  实时调试 163pop3 什么是pop3收信 pop3收信

延伸阅读

最新评论

发表评论