Skip to main content
Known Participant
April 14, 2018
Question

Adding an inline image into an AS3 created email

  • April 14, 2018
  • 1 reply
  • 578 views

I get the error:
SecurityError: Error #3769: Security sandbox violation: Only simple headers can be used with navigateToUrl() or sendToUrl().

with the code below. I just want the users email system to open and create a new email but have a jpg image inserted inline (not attached). Something like:

Hello welcome to....

   image here

Thanks for visiting...

Maybe since "image/jpeg" doesn't work as a content, is there a workaround? The only other option is to copy the image to the clipboard and have the user paste it into the email. Other than that, I'm at a loss as what to do.

I cannot go the typical route of sending the image to a server and having it send out the email. I already have that working but do to the new security laws in the UK, I need this simpler option using the users personal email.

import flash.events.MouseEvent;

import flash.net.URLRequest;

import flash.net.navigateToURL;

import com.adobe.images.JPGEncoder;

var bd:BitmapData = new BitmapData( 100, 100, false, 0x222222 );

var jpg:JPGEncoder = new JPGEncoder(50);

var ba:ByteArray = jpg.encode(bd);

emailButton.addEventListener(MouseEvent.CLICK, onClick);

function onClick(e:MouseEvent):void {

    var header:URLRequestHeader = new URLRequestHeader("Content-type", "image/jpeg");

    var request:URLRequest = new URLRequest("mailto:email?subject="+encodeURIComponent("Hello")+"&body="+encodeURIComponent("asdf"));

    request.requestHeaders.push(header);

    request.method = URLRequestMethod.POST;

    request.data = ba;

    navigateToURL(request," _blank");

}

This topic has been closed for replies.

1 reply

Known Participant
April 16, 2018

Since I haven't heard about my original post I went the auto copy way and got this code to copy part of a movieclip and put it into the clipboard. It comes up with a random named png file in the clipboard and can easily be pasted into an email by the user with ctrl-v. But is there a way to change the name and even the type of file that seems to be created here. Why the png? why the random name?

import flash.events.MouseEvent;

import flash.net.URLRequest;

import flash.net.navigateToURL;

import com.adobe.images.JPGEncoder;

import flash.display.Bitmap;

import flash.display.BitmapData;

var myBitmapData:BitmapData = new BitmapData(200, 200);

myBitmapData.draw(stef); //stef is a movieclip with a jpg photo in it.

var bmp:Bitmap = new Bitmap(myBitmapData); //not needed, but shows the image

this.addChild(bmp); //not needed, but shows the image

Clipboard.generalClipboard.clear();

Clipboard.generalClipboard.setData(ClipboardFormats.BITMAP_FORMAT, myBitmapData);

Known Participant
May 5, 2022

Did you ever figure out a way to email an image from animate cc using as3?