mardi 27 décembre 2016

Send an email with text and a snapshot attachment from Flash

Long story short, I'm trying to send an email with some dynamic text and have an image attached. The text part wasnt much of a feat. The image, however, is another thing. I've managed to get this piece of code working:

var tShC:String;
var tBnC:String;
var tStC:String;
var tMsC:String;
var hCh:String;
var lCh:String;
var fCh:String;
var sCh:String;
var pOll:String;

send.addEventListener(MouseEvent.CLICK, emailSmeta);

function emailSmeta(e:MouseEvent):void {

/*var bitmapData:BitmapData = new BitmapData(800, 600);
bitmapData.draw(stage);

var jpgEncoder:JPGEncoder = new JPGEncoder(90);

var image:ByteArray = jpgEncoder.encode(bitmapData);*/

getAllPrices();
var formVariables:URLVariables = new URLVariables();
//formVariables.jpg = image;
formVariables.senderEmail = "My msg;
formVariables.senderMsg = "Price list for: " + choice + heightTotal + " м" + "\n" +
                            tShC + "\n" +
                            tBnC + "\n" +
                            tStC + "\n" +
                            tMsC + "\n" +
                            hCh + "\n" +
                            lCh + "\n" +
                            fCh + "\n" +
                            sCh + "\n" +
                            "Total: " + pOll + "\n";
var variableRequest:URLRequest=new URLRequest("http://myadress/elkamailer.php");
variableRequest.method = URLRequestMethod.POST;
variableRequest.data = formVariables;


var variableLoader:URLLoader = new URLLoader();
variableLoader.load(variableRequest);
variableLoader.dataFormat = URLLoaderDataFormat.TEXT;

    try{
    loader.load(request);
    }
    catch (error:Error) {
    trace("it somewhat works");
    }
}

The image never comes though (yes i know it's commented right now). I've got this feeling I'm missing a tiny bit of info to make things work, but I cant figure what exactly if wrong here. Addtionaly, I've tried a ready solution from here(the very last one). It looks really neat, and almost made it working, just got this error ReferenceError: Error #1065: Variable bitmapData is not defined. My current PHP file is as simple as possible - two $_POST methods to get senderEmail and senderMsg variables, and a mail() function. I did find some more complex solution, but they were bit too... complex? I can hardly even try using stuff I barely understand. Any ideas how get this stuff running? Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire