I have implemented emailing in some of the web application I have done in the past, and also one of the recent project. So I thought this could be helpful for some of the developers, so decided to share it.
The process could be divided into 3 simple activities.
- Create the partial view, with self contained CSS
- Implement a method which would generate a string object after initialising the partial view with its model
- Send the mail
Note: The below implementaion was done for a site hosted on GearHost
Here is the method converts the partial view to a string. This requires the reference to the Controller object, the partial view name, and Model object that is required by the view.
After creating the view that you need, you can use the same code below to send the email.
Hope this helps. 🙂