flash收发邮件

作者:袖梨 2022-07-02

读取邮件代码如下:
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);
}

相关文章

精彩推荐