【问题标题】:Send an email from a flex app on both android and Iphone从 android 和 Iphone 上的 flex 应用程序发送电子邮件
【发布时间】:2015-07-17 14:57:47
【问题描述】:

我使用 flash builder 开发了适用于 android 和 iPhone 的应用程序。我希望能够在手机上打开默认电子邮件客户端并发送带有附件的电子邮件。我见过很多使用“mailto:”的例子,但是附件不支持这个。我在 Google 上对此进行了广泛搜索,但在过去 3 年中没有发现任何最新信息。

我已经制作了我希望附加的 pdf 文件,如果需要,我可以将其移动到临时目录以满足访问问题。如果不可行,我想像其他程序一样使用默认邮件程序,请告诉我如何直接从应用程序发送电子邮件。

【问题讨论】:

  • 您需要服务器端代码。要附加文件,您可以使用 File 或 FileReference 类上传文件。
  • 这不是唯一的方法,而且绝对不是我要问的。

标签: android ios actionscript-3 apache-flex flash-builder


【解决方案1】:

仅供参考,以帮助扩展 Action Script 3.0 信息库。我找不到任何方法来做我上面要求的事情。这是我用来发送带有附件的电子邮件的方法。 https://code.google.com/p/airxmail/
http://flex.coltware.com/as3-flex-air/airxmail/

import com.coltware.airxmail.INetAddress;
import com.coltware.airxmail.MailSender.SMTPSender;
import com.coltware.airxmail.MimeMessage;
import com.coltware.airxmail.RecipientType;

private function send_plain_email():void{
//  How to send plain text email
var sender:SMTPSender = new SMTPSender();
sender.setParameter(SMTPSender.HOST,"your.smtp.hostname");
sender.setParameter(SMTPSender.PORT,25);  // default port is 25
// If you use SMTP-AUTH
sender.setParameter(SMTPSender.AUTH,true);
sender.setParameter(SMTPSender.USERNAME,"username");
sender.setParameter(SMTPSender.PASSWORD,"password");

// Create email message
var message:MimeMessage = new MimeMessage();

//  Set from email address and reciepients
var from:INetAddress = new INetAddress("from-email-address@xxxx.yyyy","from label");
message.setFrom(from);

var toRecpt:INetAddress = new INetAddress("to-email-address@xxxx.yyyy","to label");
message.addRcpt(RecipientType.TO,toRecpt);

var ccRecpt:INetAddress = new INetAddress("cc-email-address@xxxx.yyyy","cc label");
message.addRcpt(RecipientType.CC,ccRecpt);

//  
message.setSubject("hello world");
//
//  Plain Text Part
//
var textPart:MimeTextPart = new MimeTextPart();
message.setSubject("Reciept for #" + job.jobs.JobID);
textPart.contentType.setParameter("charset","UTF-8");
textPart.transferEncoding = "8bit";
textPart.setText("Please see attached PDF \n You will need a PDF viewer to open \n To download the latest version of Adobe Acrobat reader, Please follow the link: http://www.adobe.com/products/acrobat/readstep.html");
message.addChildPart(textPart);

//
//  Attachment part 
//
    var filePart:MimeImagePart = new MimeImagePart();
    filePart.contentType.setMainType("application");
    filePart.contentType.setSubType("pdf");
           filePart.setAttachementFile(File.desktopDirectory.resolvePath(sfile),"WorkOrder.pdf");
            message.addChildPart(filePart);

            sender.send(message);
            sender.close();
}

【讨论】:

    猜你喜欢
    • 2011-05-08
    • 2010-12-02
    • 1970-01-01
    • 2011-08-06
    • 1970-01-01
    • 1970-01-01
    • 2013-10-09
    相关资源
    最近更新 更多