我一直在使用Grails 3.x,特别是使用邮件和iCalendar插件,我试图将iCalendar事件附加到我的邮件服务但它没有用。如果有人可以帮我修改我的代码,我将非常感激。这是:
**这部分是我的iCalendar结构** https://github.com/saw303/grails-ic-alender
byte[] iCalendarFile
{
render(contentType: 'text/calendar')
{
calendar
{
events {
event(
start: new Date(),
end: new Date(),
description: 'Event',
summary: 'Some text here',
)
}
}
}
calendar.toString.getBytes('UTF-8')
}
**然后我有我的电子邮件结构**
def mailService
def emailSender()
{
mailService.sendMail
{
multipart true
to correo
subject "Event"
body "Some text here"
attach "audiencia.ics", "text/calendar", iCalendarFile ()
}
}
iCalendarFile和emailSender都属于同一个服务类。
感谢您的支持。 :)
答案 0 :(得分:0)
这是答案
import ch.silviowangler.grails.icalender.ICalendarBuilder
class NotifierService
{
byte[] emailFile (**params**)
{
def archivo = new ICalendarBuilder()
archivo.calendar {
events {
event( start: new Date(),
end: new Date(),
description: "Description",
summary: "Some text here",
utc: true // optional
)
}
}
archivo.cal.toString().getBytes('UTF-8')
}
mailService.sendMail
{
multipart true
to email@email.com
subject "Subject"
body "Some text here"
attach "event.ics", "text/calendar", emailFile(**params**)
}