MVC render action to string - Email templating

A lot our clients require managed email templates.

Existing approaches involved tedious replacement tokens however a new approach that is possible in mvc; is to use strongly typed razor scripts  that are then serialized to a string – which you then attach as your email body.

This little helper function is really all you need: 

 

From here you can setup your model up with all your desired dynamic fields; saving hours over the old methods that are still in existence.