Sachin Walia
Sachin Walia

Reputation: 51

Play framework store emails

Hi I have a requirement where we want to store emails in database before they are sent. I am currently using version 1.2.5. I want to leverage the Mail and MVC integration offered by play as the emails will have lot of dynamic content. Is there any way it can be done in play framework. Thanks anyone for giving some direction.

Upvotes: 0

Views: 127

Answers (1)

Codemwnci
Codemwnci

Reputation: 54884

If you just want to store the content (and don't care about the headers), then you can render the MVC View template to a String, and store that in a database. You would get the String as follows

String emailContent = TemplateLoader.load("pathToEmailView").render(args);

You just have to save this to a DB in the standard way before sending your email in the normal way.

Upvotes: 1

Related Questions