Select Page
This entry has been published on 2015-03-11 and may be out of date.

Last Updated on 2015-03-11.

Scenario

On your website, you want to offer a link which opens a mail client like Outlook with mail and content suggestion. The content contains a link to a file with special characters in its name, which causes Outlook to break the link, e.g. if it contains spaces or german Umlaute.

 

Solution

Using PHP, write

<?php
$fullPath = $yourAbsoluteHttpPath . "/" . rawurlencode(rawurlencode($filename));

$mailto = "mailto:[email protected]?subject=File for you&body=Your file: ".$fullPath;

?>

<a href="<?=$mailto?>">Generate Mail</a>

Note the double usage of “rawurlencode” function. The first one is needed for HTML output, the second one will be needed for the part when Outlook takes the link code into its mail window.