如何使用AdobeAIR发送电子邮件?

如何使用AdobeAIR发送电子邮件?,air,adobe,sendmail,Air,Adobe,Sendmail,我已经搜索了如何使用AdobeAIR发送电子邮件。。但是我没有找到一个好的。他们只展示土坯亚麻。。。有些代码包含一些库 我不知道怎么用它。。有人能帮忙吗?看看Thibault Imbert的。包括源文件、一个library.swc和一个Flash示例应用程序(带有框架脚本) 更新 以下是SMTP Mailer的0.9版附带的框架脚本: import org.bytearray.smtp.mailer.SMTPMailer; import org.bytearray.smtp.encoding.J

我已经搜索了如何使用AdobeAIR发送电子邮件。。但是我没有找到一个好的。他们只展示土坯亚麻。。。有些代码包含一些库


我不知道怎么用它。。有人能帮忙吗?

看看Thibault Imbert的。包括源文件、一个library.swc和一个Flash示例应用程序(带有框架脚本)

更新 以下是SMTP Mailer的0.9版附带的框架脚本:

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.*;

// create the socket connection to any SMTP socket
// use your ISP SMTP

var myMailer:SMTPMailer = new SMTPMailer (smtp_txt.text, 25);

// 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
var myBitmap:BitmapData = new BitmapData ( stage.stageWidth, stage.stageHeight );

// encode as JPEG with quality 100
var myEncoder = new JPEGEncoder( 100 );

send_btn.addEventListener (MouseEvent.CLICK, onClick);

message_txt.text = "<img src='http://www.google.com/images/logo_sm.gif'</img><br><b>Picture file attached ! :)</b>";

function onClick ( pEvt:MouseEvent )

{

    // replace this by any DisplayObject
    myBitmap.draw ( this );

    var myCapStream:ByteArray = myEncoder.encode ( myBitmap );

    // sends HTML email
    //myMailer.sendHTMLMail ( from_txt.text, to_txt.text, subject_txt.text, "<img src='http://www.google.com/images/logo_sm.gif'</img><br><b>Picture from HTML :)</b>");

    // send HTML email with picture file attached
    myMailer.sendAttachedMail ( from_txt.text, to_txt.text, subject_txt.text, message_txt.text, myCapStream, "image.jpg");

}

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 = "Error :\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;

}


function socketErrorHandler ( pEvt:IOErrorEvent ) 

{

    // when data available, read it
    status_txt.htmlText = "Connection error !";

}
import org.bytearray.smtp.mailer.SMTPMailer;
导入org.bytearray.smtp.encoding.JPEGEncoder;
导入org.bytearray.smtp.encoding.PNGEnc;
导入org.bytearray.smtp.events.SMTPEvent;
导入flash.utils.ByteArray;
导入flash.display.BitmapData;
导入flash.display.Bitmap;
导入flash.events.*;
//创建到任何SMTP套接字的套接字连接
//使用ISP SMTP
var myMailer:SMTPMailer=新的SMTPMailer(smtp_txt.text,25);
//注册事件
//成功发送邮件时发送的事件
myMailer.addEventListener(SMTPEvent.MAIL_SENT,onMailSent);
//无法发送邮件时发送的事件
myMailer.addEventListener(SMTPEvent.MAIL_ERROR,onMailError);
//SMTPMailer成功连接到SMTP服务器时调度的事件
myMailer.addEventListener(SMTPEvent.CONNECTED,onConnected);
//SMTP服务器因不同原因断开客户端连接时调度的事件
myMailer.addEventListener(SMTPEvent.DISCONNECTED,onDisconnected);
//当客户端成功进行身份验证时调度的事件
myMailer.addEventListener(SMTPEvent.AUTHENTICATED,onAuthSuccess);
//客户端无法进行身份验证时调度的事件
myMailer.addEventListener(SMTPEvent.BAD_序列,onAuthFailed);
//拍快照
var myBitmap:BitmapData=新的BitmapData(stage.stageWidth,stage.stageHeight);
//编码为JPEG,质量为100
var myEncoder=新的JPEG编码器(100);
发送\u btn.addEventListener(MouseEvent.CLICK,onClick);
message_txt.text=“
图片文件已附加!:)”; 函数onClick(pEvt:MouseEvent) { //将其替换为任何DisplayObject myBitmap.draw(这个); var myCapStream:ByteArray=myEncoder.encode(myBitmap); //发送HTML电子邮件 //myMailer.sendHTMLMail(从_txt.text到_txt.text,主题为_txt.text,“
来自HTML的图片:”); //发送附有图片文件的HTML电子邮件 myMailer.sendAttachedMail(从_txt.text,到_txt.text,主题_txt.text,消息_txt.text,myCapStream,“image.jpg”); } onAuthFailed函数(pEvt:SMTPEvent):无效 { status_txt.htmlText=“身份验证错误”; } 函数onAuthSuccess(pEvt:SMTPEvent):无效 { status_txt.htmlText=“身份验证正常!”; } 未连接的功能(pEvt:SMTPEvent):无效 { status_txt.htmlText=“已连接:\n\n”+pEvt.result.message; status_txt.htmlText+=“Code:\n\n”+pEvt.result.Code; } mailsent上的函数(pEvt:SMTPEvent) { //当数据可用时,读取它 status_txt.htmlText=“已发送邮件:\n\n”+pEvt.result.message; status_txt.htmlText+=“Code:\n\n”+pEvt.result.Code; } 函数onMailError(pEvt:SMTPEvent):void { status_txt.htmlText=“错误:\n\n”+pEvt.result.message; status_txt.htmlText+=“Code:\n\n”+pEvt.result.Code; } 已断开连接的函数(pEvt:SMTPEvent):无效 { status_txt.htmlText=“用户已断开连接:\n\n”+pEvt.result.message; status_txt.htmlText+=“Code:\n\n”+pEvt.result.Code; } 函数socketErrorHandler(pEvt:IOErrorEvent) { //当数据可用时,读取它 status_txt.htmlText=“连接错误!”; }
请提供Adobe AIR的样品??有人有吗??该软件包包含一个框架脚本。我假设您没有Flash,因此无法访问该示例,因此我已在更新的答案中发布了框架脚本。亲爱的Dakini1978。。。我会解释我的项目。现在我正在用air、jquery和html构建简单邮件。。。。我已经尝试过搜索一些代码发送电子邮件,但我发现的闪光,亚麻。。。我知道有动作脚本…但我不知道如何将它包含在我的项目中。。。我只使用javascript(Jquery)函数调用所有函数。怎么样?。。我也尝试过加入actionscript,但仍然有错误?。。你能帮我吗?嗨,亲爱的,我已经用flash试过你的代码了。。我使用端口为587的gmail:smtp.gmail.com更改smtp。。。它可以连接…但当我按下发送按钮时,应用程序错误并显示状态“error 1:250 mx.google.com at your service”(错误1:250 mx.google.com at your service)。如果我再次按下,状态将显示为“530 5.7.0必须首先发出启动TLS命令”。r29sm1129096ybn.10'。。我知道谷歌必须启动发送电子邮件的TLS。。我的问题是如何用动作脚本启动TLS?代码:250'。。。U