# Adding Email Audit Log to email templates

<mark style="color:green;">SINCE VERSION 5.3.2.2</mark>

In case you want to render issue email audit log in your email, you must edit your email templates. The key attribute is `$!issue.auditLog` that returns a [list ](https://docs.atlassian.com/software/jira/docs/api/8.22.1/com/atlassian/jira/issue/link/LinkCollection.html)of email audit log entries or an empty list.

When selecting **Email Log** in the Field Picker dropdown list, you will get instructions on how to easily include issue email audit log information in the template.

![](/files/SwxLJVUNIrF7qc73Y9pA)

In case you want a customized display (e.g. apply different layout or styles), then you can start to add these template fragments directly into your templates and customize them according to your needs.

**Example for rendering an issue email audit log in HTML emails**&#x20;

```
#macro (addTableHead $headerLabel)
    #if ($!isJIRA61OrLater)
        <th><strong style="font-weight:normal;color:${textSubtleColour};">$headerLabel</strong></th>
    #else
        <td style="color:${textColour};font-family:${textFontFamily};font-size:${textSize};padding:0 10px 10px 0;white-space:nowrap;"><strong style="font-weight:normal;color:${textSubtleColour};">$headerLabel</strong></td>
    #end
#end
#macro (beginTd)
    #if ($!isJIRA61OrLater)
    <td>
    #else
    <td style="color:${textColour};font-family:${textFontFamily};font-size:${textSize};padding:0 0 10px 0;width:100%;">
    #end
#end
#macro (endTd)
    </td>
#end
#set($auditLog = $!issue.auditLog)
#if ($!auditLog && $!auditLog.isEmpty() == false)
<h3>Emails</h3>
<table>
<tr valign="top">
    #beginTd()
    #foreach($audit in $!auditLog)
          <div class="issue-data-block">
              <div class="actionContainer">
                  <div class="action-details">
                      $!audit.senderName $!audit.actionLabel  - <span class="date">$!audit.timestamp</span>
                  </div>
                  <div class="action-body222">
                      <table>
                          #if($!audit.from)
                          #set($fromHtml = $!audit.from)
                          <tr valign="top">
                              #addTableHead($i18n.getText("email.audit.from"))
                              #beginTd()
                              $!fromHtml
                              #endTd()
                          </tr>
                          #end
                          #if($!audit.to)
                          <tr  valign="top">
                              #addTableHead($i18n.getText("issuemail.form.to"))
                              #beginTd()
                                  <span class="email-to-full">$!{audit.to.fullLabel}</span>
                              #endTd()
                          </tr>
                          #end
                          #if($!audit.cc)
                          <tr  valign="top">
                              #addTableHead($i18n.getText("issuemail.form.cc"))
                              #beginTd()
                                  <span class="email-to-full">$!{audit.cc.fullLabel}</span>
                              #endTd()
                          </tr>
                          #end
                          #if($!audit.bcc)
                          <tr  valign="top">
                              #addTableHead($i18n.getText("issuemail.form.bcc"))
                              #beginTd()
                                  <span class="email-to-full">$!{audit.bcc.fullLabel}</span>
                              #endTd()
                          </tr>
                          #end
                          #if($!audit.emailSubject)
                          #set($subjectHtml=$!audit.emailSubject)
                          <tr  valign="top">
                              #addTableHead($i18n.getText("issuemail.form.subject"))
                              #beginTd()
                              $!subjectHtml
                              #endTd()
                          </tr>
                          #end
                          #if($!audit.emailBody)
                          #set($bodyHtml = $!audit.emailBody)
                          <tr  valign="top">
                              #addTableHead($i18n.getText("issuemail.form.body"))
                              #beginTd()
                              $!bodyHtml
                              #endTd()
                          </tr>
                          #end
                          #if($!audit.attachments)
                          #set($attachmentsHtml = $!audit.attachments)
                          <tr  valign="top">
                              #addTableHead($i18n.getText("issuemail.form.attachments"))
                              #beginTd()
                              $attachmentsHtml
                              #endTd()
                          </tr>
                          #end
                          #if($!audit.options)
                          <tr  valign="top">
                              #addTableHead($i18n.getText("issuemail.form.mail.options"))
                              #beginTd()
                                  <ul>
                                      #if($!audit.addComments)
                                      <li>$i18n.getText("issuemail.form.options.add.comments")</li>
                                      #end
                                      #if($!audit.replyToMe)
                                      <li>$i18n.getText("issuemail.form.options.from.me")</li>
                                      #end
                                      #if($!audit.addToWatcher)
                                      <li>$i18n.getText("issuemail.form.options.add.to.watchers")</li>
                                      #end
                                  </ul>
                              #endTd()
                          </tr>
                          #end
                      </table>
                  </div>
              </div>
          </div>
    #end
    #endTd()
</tr>
</table>
#end
```

**Example for rendering issue email audit log information in TEXT emails**

```
#set($auditLog = $!issue.auditLog)
#if ($!auditLog && $!auditLog.isEmpty() == false)
Emails:
#foreach($audit in $!auditLog)
Action:$!audit.senderName $!audit.actionLabel - $!audit.timestamp
------------------
#if($!audit.from)
$stringUtils.leftPad($i18n.getText("email.audit.from"), $padSize) $!audit.auditLogEntry.from
#end
#if($!audit.to)
$stringUtils.leftPad($i18n.getText("issuemail.form.to"), $padSize) $!{audit.auditLogEntry.to}
#end
#if($!audit.cc)
$stringUtils.leftPad($i18n.getText("issuemail.form.cc"), $padSize) $!{audit.auditLogEntry.cc}
#end
#if($!audit.bcc)
$stringUtils.leftPad($i18n.getText("issuemail.form.bcc"), $padSize) $!{audit.auditLogEntry.bcc}
#end
#if($!audit.emailSubject)
$stringUtils.leftPad($i18n.getText("issuemail.form.subject"), $padSize) $!audit.auditLogEntry.emailSubject
#end
#if($!audit.emailBody)
$stringUtils.leftPad($i18n.getText("issuemail.form.body"), $padSize) $!audit.auditLogEntry.emailBody
#end
#if($!audit.attachments)
$stringUtils.leftPad($i18n.getText("issuemail.form.attachments"), $padSize) $!audit.auditLogEntry.attachments
#end
#if($!audit.options)
$stringUtils.leftPad($i18n.getText("issuemail.form.mail.options"), $padSize): #if($!audit.addComments)$i18n.getText("issuemail.form.options.add.comments"), #end #if($!audit.replyToMe)$i18n.getText("issuemail.form.options.from.me"), #end #if($!audit.addToWatcher)$i18n.getText("issuemail.form.options.add.to.watchers")#end
#end
#end
#end
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.meta-inf.hu/email-this-issue/email-this-issue-for-jira-server-data-center/documentation/outgoing-emails/email-templates/adding-email-audit-log-to-email-templates.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
