一聚教程网:一个值得你收藏的教程网站

热门教程

flash收发邮件

时间:2022-07-02 17:04:38 编辑:袖梨 来源:一聚教程网

读取邮件代码如下:
const VK_RETURN:String="rn";
const cmd:ByteArray=new ByteArray();
//163邮箱,你自己的帐号和密码
const user:String="帐号";
const pass:String="密码";

var Server:String="pop.163.com";
var Port:int=110;
var Response:String;

var socket:Socket=new Socket();
socket.addEventListener( "connect" , onConnectEvent);
socket.addEventListener( "socketData" , onSocketDataEvent);
socket.connect(Server,Port);
function onConnectEvent(evt:Event):void {
       cmd.writeUTFBytes("user "+user+VK_RETURN);
       cmd.writeUTFBytes("pass "+pass+VK_RETURN);
       cmd.writeUTFBytes("list"+VK_RETURN);
       cmd.writeUTFBytes("retr 1"+VK_RETURN);//读取第一封邮件
       socket.writeBytes(cmd);
       socket.flush();
}
function onSocketDataEvent(evt:ProgressEvent):void {
       Response=socket.readMultiByte(socket.bytesAvailable,"gbk");
       trace(Response);
}

热门栏目