<?xml version="1.0" encoding="utf-8"?>
<page xmlns="http://projectmallard.org/1.0/" xmlns:its="http://www.w3.org/2005/11/its" type="topic" id="mail-composer-message-templates-variables" xml:lang="oc">

  <info>
   <desc>Configure variables in templates and reuse items from the message you reply to</desc>
   
   <link type="guide" xref="mail-composer-message-templates#options"/>

 <revision pkgversion="3.5.90" version="0.3" date="2012-08-17" status="draft"/>
 <credit type="author">
   <name its:translate="no">Andre Klapper</name>
   <email its:translate="no">ak-47@gmx.net</email>
 </credit>
 <credit type="author">
   <name its:translate="no">Novell, Inc</name> <!-- Content partially from https://help.gnome.org/users/evolution/2.32/b1dlaazl.html.en -->
 </credit>
 
 <include xmlns="http://www.w3.org/2001/XInclude" href="legal.xml"/>
     

  </info>

<title>Using Variables in Templates</title>

<section id="configure">	
<title>Configuring Variables for Message Templates</title>
<steps>
<item><p>Select <guiseq><gui>Edit</gui><gui>Plugins</gui></guiseq>.</p></item>
<item><p>Click <gui>Templates</gui>.</p>
<note style="tip"><p>If a plugin is not available under <guiseq><gui>Edit</gui><gui>Plugins</gui></guiseq>, then please ask in a support forum of your distribution. Your distribution might have decided to disable some plugins or to ship plugins in a separate package.</p></note>
</item>
<item><p>Click the <gui>Configuration</gui> tab.</p></item>
<item><p>You can add, edit or remove the key-value pairs. You can specify any number of key-value pairs.</p></item>
</steps>
 <p>In any template, the occurrence of every $key is replaced by the value it has in the configuration. For example, if you set the key to Manager and the value to Harry, any occurrence of $Manager is replaced by Harry in the message.</p>
 <p>Assume that you have 1000 message templates with your current manager's name in them. When the current manager is replaced by a new one, it is not easy for you to manually replace the manager's name in all the 1000 messages. If the messages have a $Manager key value, you can reset the value in the Configuration tab of this plugin.</p>
 <p>By default, the entire environment variables are used as a key-value pair. An occurrence of $env_variable is replaced by the value it carries. For example, an occurrence of $PATH in your template is replaced by its value when the template is used.</p>
 <p>The replacement process uses the following order of precedence:</p>
 <steps>
  <item>
<p>$key is replaced by the value set for it in the Configuration tab of the Templates plugin.</p>
  </item>
  <item>
<p>If the key is not found, it is then replaced with the value of its environment variable.</p>
  </item>
  <item>
<p>If key is neither a configuration option nor an environment variable, no changes are made.</p>
  </item>
 </steps>
</section>

<section id="reply-variables">
<title>Using Elements From a Message in a Template When Replying</title>
<p>Templates can contain more than just the predefined set of <link xref="#configure">key-value pairs</link>. You can also get any message header values from the email that you are applying the template on, plus the complete message body.</p>

<p its:locNote="TO TRANSLATORS: Do NOT translate $ORIG[subject] and $ORIG[body] in this sentence!">In order to do this, use the format <code>$ORIG[header_name]</code> and replace the variable <code>header_name</code> by the actual header. For example, if you would like to insert the subject line of the message that you reply to, use <code>$ORIG[subject]</code>. To insert the complete body, use <code>$ORIG[body]</code>.</p>

<p its:locNote="TO TRANSLATORS: Do NOT translate $ORIG[body] and $ORIG[reply-to] in this sentence!">If no replacement for a variable is found, the variable is not removed (except for <code>$ORIG[body]</code>) but left in place so that you see that something went wrong. This could happen when trying to use headers that are not necessarily always available in the original message (for example <code>$ORIG[reply-to]</code>).</p>
</section>

</page>
