インターネットから入手したAdobe Flashとアクションスクリプト3.0で電子メールを送信するためのソースコードを使用しようとしています..ここでは添付ファイル付きの電子メールを送信したい..しかし、それはまだプレーヤーとしてAdobe Airを使用しています..そして今私はしたいですFlash Player 10 を使用します。そのため、air ライブラリが提供する 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.*;
/* air ライブラリ用 */
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」、「テスト」、「テスト本文」、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;
}