我尝试使用一些源代码来使用我从互联网上获得的 adobe flash 和 action script 3.0 发送电子邮件。在这里我想发送带有附件的电子邮件。但它仍然使用 adobe air 作为播放器。现在我想使用它 flash player 10 .. 所以我不能使用 air library 提供的 flash.filesystem .. 如果我使用 flashplayer 10 作为播放器,我知道如何更改它......以及我的代码如何变成???任何机构都可以提供帮助????
import org.bytearray.smtp.mailer.SMTPMailer;
import org.bytearray.smtp.encoding.JPEGEncoder;
import org.bytearray.smtp.encoding.PNGEnc;
import org.bytearray.smtp.events.SMTPEvent;
import flash.utils.ByteArray;
import flash.display.BitmapData;
import flash.display.Bitmap;
import flash.events.*;
/* 用于空气库*/
import flash.filesystem.FileStream;
import flash.filesystem.File;
// create the socket connection to any SMTP socket
// use your ISP SMTP
var myMailer:SMTPMailer = new SMTPMailer ("smtp.mail.yahoo.com", 25);
var fileRef:FileReference;
// register events
// event dispatched when mail is successfully sent
myMailer.addEventListener(SMTPEvent.MAIL_SENT, onMailSent);
// event dispatched when mail could not be sent
myMailer.addEventListener(SMTPEvent.MAIL_ERROR, onMailError);
// event dispatched when SMTPMailer successfully connected to the SMTP server
myMailer.addEventListener(SMTPEvent.CONNECTED, onConnected);
// event dispatched when SMTP server disconnected the client for different reasons
myMailer.addEventListener(SMTPEvent.DISCONNECTED, onDisconnected);
// event dispatched when the client has authenticated successfully
myMailer.addEventListener(SMTPEvent.AUTHENTICATED, onAuthSuccess);
// event dispatched when the client could not authenticate
myMailer.addEventListener(SMTPEvent.BAD_SEQUENCE, onAuthFailed);
// take the snapshot
send_btn.addEventListener (MouseEvent.CLICK, onClick);
function onClick ( pEvt:MouseEvent )
{
/*How to change this attachment by using adobe flash player library code and action script 3.0, not adobe air player library ?????? */
/* 从这里改变............................*/
var attachmentFile:File=File.documentsDirectory;
attachmentFile = attachmentFile.resolvePath("file/Questions.xml");
var stream:FileStream = new FileStream();*/
var myCapStream:ByteArray = myEncoder.encode ( fileRef );
stream.open(attachmentFile,FileMode.READ);
stream.readBytes(myCapStream,0,stream.bytesAvailable);
stream.close();
/* 直到这里.......................... */
myMailer.authenticate("x@yahoo.com","xxxx"); myMailer.sendAttachedMail ("x@yahoo.com", "y@gmail.com", "test", "test body", myCapStream, );
}
function onAuthFailed ( pEvt:SMTPEvent ):void
{
status_txt.htmlText = "Authentication Error";
}
function onAuthSuccess ( pEvt:SMTPEvent ):void
{
status_txt.htmlText = "Authentication OK !";
}
function onConnected ( pEvt:SMTPEvent ):void
{
status_txt.htmlText = "Connected : \n\n" + pEvt.result.message;
status_txt.htmlText += "Code : \n\n" + pEvt.result.code;
}
function onMailSent ( pEvt:SMTPEvent )
{
// when data available, read it
status_txt.htmlText = "Mail sent :\n\n" + pEvt.result.message;
status_txt.htmlText += "Code : \n\n" + pEvt.result.code;
}
function onMailError ( pEvt:SMTPEvent ):void
{
status_txt.htmlText = "Notification :\n\n" + pEvt.result.message;
status_txt.htmlText += "Code : \n\n" + pEvt.result.code;
}
function onDisconnected ( pEvt:SMTPEvent ):void
{
status_txt.htmlText = "User disconnected :\n\n" + pEvt.result.message;
status_txt.htmlText += "Code : \n\n" + pEvt.result.code;
}