News Flash

02/27/07: Jon Aldinger, Mark Huot, & Dan Mall present swfIR: swf Image Replacement

02/21/07: flashBug is an Actionscript class that writes debug information out to Firebug's console

02/06/07: Geoff Stearns and Bobby van der Sluis join forces to create one Flash embed method to rule them all: SWFFix

11/16/06: SWFUpload adds the advantages of uploading files with Flash to your web applications.

Categories

Sponsored Links

Search

FP8 mailto with subject

« »

FP8 mailto with subject

(0)

(11)

10/09/05, 04:17 PM

Yesterday I ran into an interesting quirk involving the Flash Player 8 while doing some freelance work. It deals with creating a mailto link in Flash that includes a subject line and testing it locally.

All the client needed was a simple link that would open up the user's email program and insert the proper email address and subject line. So as I've always done, I created a button and added the following code:

on(release) {
	getURL("mailto:email@address.net?subject=Test");
}

Nothing fancy there, just your most basic way to send an email with a subject line. I test it out in my browser like usual... Outlook opens up a "New Message" window... "To:" address is prepopulated, but the "Subject:" line is blank. Didn't expect that to happen.

So I thought maybe Flash was stripping out the "?" and everything after it for some reason. To test my theory, I try linking to Google and adding "?testing" to the end of the URL, like so:

on(release) {
	getURL("http://www.google.com/?testing");
}

When I click that link, the following message box appears:

Macromedia Flash Player Security: Macromedia Flash Player has stopped a potentially unsafe operation. The following local application on your computer or network: (c:\Documents and Settings\...\testlink.swf) is trying to communicate with this Internet-enabled location: (www.google.com). To let this application communicate with the Internet, click Settings. You must restart the application after changing your settings.

That reminded me about the new Flash Player 8 security changes and how local content cannot access remote files. I wasn't sure if that was related to my problem, so I clicked "Settings..." and I was brought to the Flash Player Settings Manager page.

It was the first time I'd come across the Settings Manager, and I was surprised to see the Advanced Settings are actually set in special Flash movie you access from a webpage on Macromedia's website. If you haven't seen it yet, here's a screenshot:

Macromedia Flash Player Settings Manager - Global Security Settings

Note: The Settings Manager that you see above is an image; it is not the actual Settings Manager itself.

The obvious next step here was to edit my locations of trusted local content. So I clicked the "Edit locations..." dropdown, selected "Add Location," and I was presented with this:

Macromedia Flash Player Settings Manager - Global Security Settings

Bravo Macromedia! I applaud your work on this. The path I needed to add was listed right there for me to copy and paste. So I copy and paste the directory (I didn't include the file, because I want to trust the entire directory) and click "Confirm."

The path is now displayed as a trusted location:

Macromedia Flash Player Settings Manager - Global Security Settings

So I close the browser and reopen my test page. I click the link and I am successfully brought to http://www.google.com/?testing. Great. Now time to test if this affects my "mailto" link. So I change the getURL url back to "mailto:email@address.net?subject=Test" and give it a shot. I click the link, and Outlook opens with both the "To:" and "Subject:" fields prepopulated as I wish. Woohoo!

This is of course leading me to believe that when run locally, the Flash Player 8 does strip out the question mark and everything after it in the url, but does not alert the user, unless you make the security setting change that I did. To be 100% sure of my theory, I change the link to the following:

on(release) {
	getURL("index.html?testing");
}

I create a quick default index.html file locally and give it a test run. I click the link and... I'm only brought to index.html... no "?testing" at the end of it. Not what I expected. I tried using "GET" as well and that didn't work:

on(release) {
	getURL("index.html?testing","","GET");
}

So what have I learned from all of this? It appears that when run locally, Flash Player 8 will always strip the question mark and anything following it off the end of the url of the getURL function, regardless of security settings. However, if the url in the getURL function is a mailto link AND your security settings are set to trust your local location, it will prepopulated the values as you wish.

Of course, when the file is uploaded to the internet this isn't an issue, but if you test your work locally first, this knowledge will hopefully save you some headaches.

Add this to your del.icio.us bookmarks

Trackback Pings to FP8 mailto with subject

TrackBack URL: http://www.flashpearls.com/cgi-bin/mt-tb.cgi/167.

Manton's Comments on FP8 mailto with subject

Manton
10/27/05, 07:55 PM

Thanks! That tidbit about the "?" on the local machine was very handy. I would have been tearing my hair out for ages had I not read this!

Ishtar's Comments on FP8 mailto with subject

Ishtar
11/03/05, 04:49 AM

you are the man!!!!!!!!!!!!!!
Thank you very much!!!!!!!!!!!!!!!!
you save from a heart attack!!!!!!!!!

tomiko's Comments on FP8 mailto with subject

tomiko
08/16/06, 10:16 PM

Very nice summary -- I had the same problem, and your article provided me with a simple answer and solution. Thanks for the information!

Greg's Comments on FP8 mailto with subject

Greg
11/22/06, 08:00 AM

THANK YOU! THANK YOU! THANK YOU! THANK YOU! THANK YOU!
I've wasting my time for long hours!!!
THANK YOU!

Chris's Comments on FP8 mailto with subject

Chris
05/08/07, 05:23 AM

Before wasting hours, a quick google search and you have the answer.... Thank you for this tip.

Barry's Comments on FP8 mailto with subject

Barry
08/30/07, 07:30 AM

Does anyone know if it is possible in Flash/html or Java to get a mailto link to insert images(jpeg) into a mail aswell as the recipient and subject. I have found html code which allows you to insert text into the body of the email but not an image. Any help on this would be great.

jesus's Comments on FP8 mailto with subject

jesus
09/04/07, 12:12 PM

Perfect! you action script works awesome for me! Thanks a lot man!

james's Comments on FP8 mailto with subject

james
11/25/07, 12:51 PM

ok .. but need help with mailto: locally for flash projector email capacity. The flash exe will be distributed and you can not expect people to understand flash security so is there a way to simply invoke the local email client from a local flash exe?? thanks!

Ahmad's Comments on FP8 mailto with subject

Ahmad
01/05/08, 05:56 AM

It really helped me thankyou....

Renee's Comments on FP8 mailto with subject

Renee
02/27/08, 01:16 PM

Thanks! you saved me from wasting time as I found this post before I started.

ozzy's Comments on FP8 mailto with subject

ozzy
11/25/10, 03:29 AM

thanks so much!!! you saved my ass! excelent clue.

Post your thoughts on FP8 mailto with subject



(note: gravatars are enabled)


Remember Me?