Details
| Macro | mailto |
|---|---|
| Author | James Mortimer |
| DateCreated | 2007-02-20 |
| LatestVersion | 2 |
| ConfluenceVersion | 2.2.10, 2.3.3 |
| Description | Renders a block of text as a mailto, using urlencode to convert spaces and newlines properly. |
| Category | Utility |
Usage
{mailto}
body text of your message
{mailto}
{mailto:<email address>|subject=<subject>|alias=<alias>|showBody=true|showIcon=true|appendLink=true}
body text of your message
{mailto}
| Parameter | Required | Description |
|---|---|---|
| param0 or email | |
The email address to send the message to (default=first_last@domain.com) |
| param1 or subject | |
The subject line to use for the email (default=WIKI) |
| param2 or alias | |
The alias to use for the link (default=Send <subject> email to <email>) |
| showIcon | |
if true, shows an envelope icon beside the link (default=true) |
| showBody | |
if true, shows the body of the email in a standard confluence panel below the link (default=true) |
| appendLink | |
if true, appends a link to the current page to the email body (default=true) |
Source
## Check parameters #if($paramemail && $paramemail.length()>0) #set($email=$paramemail) #else #if($param0 && $param0.length()>0) #set($email=$param0) #else #set($email="first_last@domain.com") #end #end ## #if($paramsubject && $paramsubject.length()>0) #set($subject=$paramsubject) #else #if($param1 && $param1.length()>0) #set($subject=$param1) #else #set($subject="WIKI") #end #end ## #if($paramalias && $paramalias.length()>0) #set($alias=$paramalias) #else #if($param2 && $param2.length()>0) #set($alias=$param2) #else #set($alias="Send $subject email to $email.") #end #end #if(!$paramshowIcon || $paramshowIcon=="true") #set($emailIcon=' <sup><img class="rendericon" src="/images/icons/mail_small.gif" height="12" width="13" align="absmiddle" alt="" border="0"/></sup>') #else #set($emailIcon="") #end ## #set($showBody="true") #if($paramshowBody)#set($showBody=$paramshowBody)#end ## ## Get a newline character #set($newline="") #set($newline=$newline.format('%n',null)) ## ## Remove leading and training newlines and returns #set($body=$body.replaceAll("^(${newline}|\r)*","")) #set($body=$body.replaceAll("(${newline}|\r)*$","")) ## ## Append a link to the current page to email body (just in the message, not the display) #if(!$paramappendLink || $paramappendLink=="true") #set($bodymsg="${body}${newline}$action.getGlobalSettings().getBaseUrl()$content.getUrlPath()") #else #set($bodymsg=$body) #end ## ## URL Encode parameters #set($emailEnc=$webwork.urlEncode($email)) #set($subjectEnc=$webwork.urlEncode($subject)) #set($bodyEnc=$webwork.urlEncode($bodymsg)) ## ## pluses are not used for spaces in mailto: encoding #set($subjectEnc=$subjectEnc.replaceAll("[+]","%20")) #set($bodyEnc=$bodyEnc.replaceAll("[+]","%20")) ## ## #set($url="mailto:$emailEnc?Subject=$subjectEnc&Body=$bodyEnc") ## ## Output ## <p><span class="nobr"><a href="$url">${alias}${emailIcon}</a></span></p> #if($showBody=="true") ## insert newlines into html versions #set($body=$body.replaceAll(${newline},"</br>")) <div class="panel"> <div class="panelContent"> <b>$subject</b></br> $body </div> </div> #end
Example
{mailto}
body text of your message
{mailto}
{mailto:name@domain.com|subject=Just testing mailto|appendLink=false|alias=Click here to send message|showBody=true|showIcon=true}
This is just a test of the mailto macro
{mailto}
Documentation
Dependancies
This macro depends on
- default mail program configured in IE or environment that reads mail-to html tags
- message must be less than a certain size (about 2kb I think)
Issues
-

Comments (1)
Aug 27
István Lőrincz says:
Nice macro, but I have a litle problem with it. It dose't works for non US-ASCII...Nice macro, but I have a litle problem with it. It dose't works for non US-ASCII charsets. It is rendered correct in my browser(Firefox), but my mail program (Thunderbird) displays only question marks in subject and/or body after entering a non US-ASCII character e.g. ő. Any idea what's going wrong?
I've used the folowing snipet:
{mailto:lorincz.i@gmail.com|subject=Test mail árvíztűrő tükörfúrógép|alias=JIRA Adminisztrátor|showBody=true|showIcon=true|appendLink=true} Text, text, text ... The next line is the problematic one :-(. ÁRVÍZTŰRŐ TÜKÖRFÚRÓGÉP árvíztűrő tükörfúrógép New line {mailto}