Skip to main content
Known Participant
September 3, 2008
Question

Insert newline into mailto?

  • September 3, 2008
  • 1 reply
  • 1894 views
Hi all:
I using AS3 to create a mailto: link from within an swf.
I have this code working:

mailto_mc.addEventListener(MouseEvent.CLICK, mouseDownHandler);
function mouseDownHandler(event:MouseEvent):void {
navigateToURL(new URLRequest("mailto:some_email@yahoo.com?subject=Check out this new video!&body=Some body text"));
}

Anyone know of a way to insert newlines into the message and have them passed correctly to the email client?
Thanks.
This topic has been closed for replies.

1 reply

voxLAuthor
Known Participant
September 3, 2008
A bit more research and experimenting yielded this answer:

var text:String = "First line of message.\n Second line of message";

mailto_mc.addEventListener(MouseEvent.CLICK, mouseDownHandler);
function mouseDownHandler(event:MouseEvent):void {
navigateToURL(new URLRequest("mailto:some_email@yahoo.com?subject=Check out this new widget!&body="+text)); // Newline isn't passed
}



// This will pass the newline to the body of the email message:
var mailMsg:URLRequest = new URLRequest("mailto:afriend@gmail.com");
var variables:URLVariables = new URLVariables();
variables.subject = "hello";
variables.body = text;
mailMsg.data = variables;
mailMsg.method = URLRequestMethod.GET;
navigateToURL(mailMsg);