Extending Community Server Email Services

I needed to send out an email to members of a billing group in my Community Server Business App when a job was marked complete.  I could have done something simple, but I wanted to do something cool and dig a bit deeper in the API since I had the opportunity.  So I created a new emails.xml <email /> template and populated those template email tokens with data from custom objects.  Here’s the email that is produced before I get into the geeky details.

 

 

Notice the nice HTML formatting.  I typically duplicate the site’s styling whenever I add email services to an application, which is what I’ve tried to do here.  CS2007’s support for HTML email is also much improved over earlier versions, so there’s actually a lot you can do with email formatting now.

Below is the template I added to the /languages/emails/emails.xml file.  You’ll notice that [PM], [Jobno] and [Job] are original email tokens we’ll need to populate when generating the JobComplete emailType.

 

I wrote an email provider to handle the email processing.  It wasn’t necessary to construct it as a provider, but I wanted to stay as close to the original Mailroom model as possible.  The Mailroom XmlEmailTemplateProvider reads in the emails.xml file, so all I had to do was handle the [PM], [Jobno] and [Job] tokens.  

 

Then to populate those tokens I used the CS EmailTemplate provider with a custom EmailType (JobEmailType.JobComplete) and called the EmailHelper GetJobPostFields() method above.

Article written by

A long time developer, I was an early adopter of Linux in the mid-90's for a few years until I entered corporate environments and worked with Microsoft technologies like ASP, then .NET. In 2008 I released Sueetie, an Online Community Platform built in .NET. In late 2012 I returned to my Linux roots and locked in on Java development. Much of my work is available on GitHub.