Flex/AIR: Sending email with embedded image.. how?

2020-02-10 10:01发布

问题:

I'm making a Flex AIR application that will produce a giftcard from a webcam picture. This giftcard needs to be sent in an e-mail to a recipient provided in the program. Should I upload the picture to a server and use php to send the mail?

回答1:

You could try using SMTP Mailer, an ActionScript library for SMTP. It supports attachments, so it should meet your needs.

http://www.bytearray.org/?p=27



回答2:

        var mailer:SMTPMailer = new SMTPMailer("localhost",25);
        var myBitmap:BitmapData = new BitmapData(photo.width,photo.height);
        myBitmap.draw(photo);
        var myEncoder:JPEGEncoder = new JPEGEncoder(100);
        var myCapStream:ByteArray = myEncoder.encode (myBitmap);
        var subject:String = "subject goes here";
        var content:String = "This is content";
        mailer.sendAttachedMail ( "noreply@nobody", toEmail.text,subject, content, myCapStream, "style.jpg");

I used SMTPMailer 0.9 that is hosted in google code. 0.6 has a problem with image attachment.For email, "Test Mail Server Tool" is used to simulate the mail server.