Customizing email content for MS Outlook
MS Outlook normally presents plain text emails with a variable-width font, and as a result the ticket properties table will most certainly look like a mess in MS Outlook. This can be fixed with some customization of email template.
Replace the following second row in the template:
${ticket_props}
For Trac 1.4 and later, Jinja2 template:
-------------------------------------------------------------------------- # set sel = ('Reporter', 'Owner', 'Type', 'Status', 'Priority', 'Milestone', 'Component', 'Severity', 'Resolution', 'Keywords') # for a in ticket_props.replace('|', '\n').splitlines()[1:-1]|map('trim'): # set a = a.split(':', 1)|map('trim')|list # if len(a) > 1 and a[0] in sel: ${'%-*s %s'|format(12, a[0] + ':', a[1])} # endif # endfor --------------------------------------------------------------------------
For Trac 1.2 and early, Genshi template:
-------------------------------------------------------------------------- {% with pv = [(a[0].strip(), a[1].strip()) for a in [b.split(':') for b in [c.strip() for c in ticket_props.replace('|', '\n').splitlines()[1:-1]] if ':' in b]]; sel = ['Reporter', 'Owner', 'Type', 'Status', 'Priority', 'Milestone', 'Component', 'Severity', 'Resolution', 'Keywords'] %}\ ${'\n'.join('%-*s %s' % (12, p[0]+':', p[1]) for p in pv if p[0] in sel)} {% end %}\ --------------------------------------------------------------------------
The table of ticket properties is replaced with a list of a selection of the properties. A tab character separates the name and value in such a way that most people should find this more pleasing than the default table when using MS Outlook.
--------------------------------------------------------------------------
Reporter: | jonas@example.com |
Owner: | anonymous |
Type: | defect |
Status: | assigned |
Priority: | lowest |
Milestone: | 0.9 |
Component: | report system |
Severity: | major |
Resolution: | |
Keywords: |
Changes:
* component: changeset view => search system
* priority: low => highest
* owner: jonas => anonymous
* cc: daniel@example.com =>
daniel@example.com, jonas@example.com
* status: new => assigned
Comment:
I'm interested too!
--
Ticket URL: <http://example.com/trac/ticket/42>
My Project <http://myproj.example.com/>
Important: Only those ticket fields that are listed in sel
are part of the HTML email. If you have defined custom ticket fields which are to be part of the email, then they have to be added to sel
. Example:
sel = ['Reporter', ..., 'Keywords', 'Custom1', 'Custom2']
However, the solution is still a workaround to an automatically HTML-formatted email.