I'm having a bit of trouble combining two things, sending text variables from flash and an image from flash. Here's what I do to email the image:
private function emailImage(imageToSend:MovieClip):void {
trace("Sending Email");
var data1:BitmapData = new BitmapData(imageToSend.width, imageToSend.height);
data1.draw(imageToSend);
var en:JPGEncoder = new JPGEncoder(80);
var bArray:ByteArray= en.encode(data1);
var header:URLRequestHeader = new URLRequestHeader("Content-type", "application/octet-stream");
var request:URLRequest = new URLRequest();
request.requestHeaders.push(header);
request.url = "http://192.168.1.117/mail.php";
request.method = URLRequestMethod.POST;
request.data = bArray;
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.BINARY;
loader.addEventListener(Event.COMPLETE, MailCompleteHandler);
try
{
loader.load(request);
}
catch(error:Error)
{
trace("Unable to load URL");
}
}
And to email text variable I do this:
private function sendDataDB(Path:String) {
var urlRequest:URLRequest = new URLRequest(Path);
var loader:URLLoader = new URLLoader;
urlRequest.method = URLRequestMethod.POST;
var vars:URLVariables = new URLVariables;
vars.cardID = cardID;
vars.userName = userName;
urlRequest.data = vars;
loader.dataFormat = URLLoaderDataFormat.TEXT;
loader.addEventListener(Event.COMPLETE,userDataStored);
loader.load(urlRequest);
}
But how do I do both, I want to send some text that would change for each user to be used as the body of the text and the email address but also send the picture to attach.
Thanks
EDIT: Would it work to append data to the end of the URL:
request.url = "http://192.168.1.117/mail.php";
Not sure how to go about this, the correct format for the URL or how to read it in on the PHP side.