当前位置:软件学习 > Flash >>

flash收发邮件

读取邮件代码如下:
const VK_RETURN:String="\r\n";
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);
}

补充:flash教程,As3.0
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,