Skip to content

Instantly share code, notes, and snippets.

@ilmoralito
Created March 21, 2014 17:55
Show Gist options
  • Save ilmoralito/9691820 to your computer and use it in GitHub Desktop.
Save ilmoralito/9691820 to your computer and use it in GitHub Desktop.
Sending email from quartz using some view
//in quartz job
package com.testing
class SampleJob {
def mailService
static triggers = {
simple repeatInterval: 10000l // execute job once in 100000 seconds, just to try something
}
def execute() {
mailService.sendMail {
to "amakenadog@gmail.com"
from "amakenadog@gmail.com"
subject "Hello"
body view:"/shared/templ", model:[users:User.list()]
}
println "Sended"
}
}
//view in /views/shared/templ.gsp
<%@ page contentType="text/html"%>
<h1>My users list</h1>
<ul>
<g:each in="${users}" var="${user}">
<li>${user.username}</li>
</g:each>
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment