Community Server Email Basic Food Group

I needed to create an Email Alert function the other day to send emails to a designated Community Server Role when a certain background task encountered an error.  Posting an event to the CS Event log wasn’t good enough for us this time.  In the process of assemblying the custom email function I thought it a good example of the basic ingredients that comprise the Community Server email process.

First we’re going to create a new Email Alert template in the \languages\en-US\emails\emails.xml template file.  We’ve specified both TEXT and HTML versions of the message and will need to populate our tokens, “ErrorType”, “InternalExceptionUrl”, “ExternalExceptionUrl”, etc.  The email will tell us an error has occurred and provide direct links to the site Exception Log.  There’s also a “DistributionList” token (in the HTML template) which I like to include in my custom email processes because I think it’s useful for each recipient to know who all is receiving the message.



The background task creates an instance of a custom DBVTEmailsProvider and gets the ball rolling with a populated MailPost object and the role to whom we want to send the email.


The Email Provider populates the tokens for each user in the role and places the email message in the Email Queue.  Highlighted is the process of populating the tokens via an EmailHelper class.

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.