Pitfalls with mailto-Links in Flash

October 20th, 2009 by max » (3) » AS3

In my last project I had some issues with IE8 (at customer-side), Mail (on agency-side) and my way of placing mailto-links.

In this project, the email-address and the subject come from a XML. This was my first setup:

XML-Node

<node contactAddress="support@acme.com" contactSubject="Kontakt über Homepage">

(Please notice: the german »Umlaut« in the subject)

AS3 (excerpt)

private function mailto(e:MouseEvent):void {
var mailaddress:String=XML.node.attribute("contactAddress");
var mailsubject:String=XML.node.attribute("contactSubject");
navigateToURL( new URLRequest( "mailto:"+mailaddress+"?subject="+mailsubject));
}

So, let’s see, what happened with different clients on different OS:

IE7, IE6, FF, Safari on WinXP worked without any problems (with Outlook Express). IE8 on WinXP opens a new Window with an error message (»Navigation wurde abgebrochen« / »Navigation to the webpage was canceled«), but opens Outlook (Express and Outlook 2007) with correct recipient and correct subject.
Every browser on Mac opens up Mail, but didn’t open a new eMail with recipient or subject.

To cut a long debugging-story short: please no german umlauts in mailsubject, so changing the XML-node the following mail, solved the problem:

<node contactAddress="support@acme.com" contactSubject="Kontakt per Homepage">

Nice, but still IE8 opens up a ugly window with the cancelation message. The solution here was the target-attribute of the navigateToUrl-Method: default is “_blank”, which I thought was the correct way to handle it, because I didn’t want the page to unload, if the mailto-Link was clicked. Turned out, that when you use the code in following way, the page doesn’t unload and new tabs/windows are surpressed.

private function mailto(e:MouseEvent):void {
var mailaddress:String=XML.node.attribute("contactAddress");
var mailsubject:String=XML.node.attribute("contactSubject");
navigateToURL( new URLRequest( "mailto:"+mailaddress+"?subject="+mailsubject), "_self");
}

Conclusion: don’t use Umlauts (and probably no other special characters) with OS X, don’t use “_blank” or default.