Template for Sending an Inquiry's History

The history of an inquiry consists of the diary entries that were subsequently added to the inquiry. For the customer’s convenience, such a history can be sent to her by means of this e-mail template. Here is a simple example:

inquiry_history_email_subject:
[#{{inquiry.id}}] {{inquiry.summary}}
inquiry_history_email_body:
Ticket ID: #{{inquiry.id}}
Summary: {{inquiry.summary}}
{% if inquiry.contact %}Inquiry by: {{inquiry.contact}}{% endif %}
{% if inquiry.owner %}Responsible: {{inquiry.owner}}{% endif %}
Web link: https://www.example.org/inquiries/{{inquiry.id}}

Inquiry History
===============
{% for diary in inquiry.external_diaries %}
------------------------------------------------------------------------
{{diary.created_at | date:'%Y-%m-%d %H:%M'}} - {{diary.created_by}}: {{diary.summary}}

{{diary.notes}}
{% endfor %}
------------------------------------------------------------------------

-- 
The Company Ltd. | Customer Support
Sample St. 99, 99999 Sampletown
Phone: 099 99 99 98, Fax: 099 99 99 99
http://www.example.org

In this template, a for loop with its control variable diary is used to output the relevant field contents of all the inquiry's diary entries.