Edgewall Software

Customizing e-mail content for MS Outlook

MS Outlook normally presents plain text e-mails 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 the e-mail template.

Replace the following second row in the template:

${ticket_props}

with this (requires Python 2.6 or later):

--------------------------------------------------------------------------
{% 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\t%s' % (format(p[0]+':', ' <12'), 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.

#42: testing
--------------------------------------------------------------------------
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 mail. If you have defined custom ticket fields which are to be part of the mail, 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 e-mail.

Last modified 10 months ago Last modified on Apr 3, 2017, 5:04:54 AM
Note: See TracWiki for help on using the wiki.