2016-07-29 22 views
0

我一直在使用Grails 3.x,特别是使用邮件和iCalendar插件,我尝试将iCalendar事件附加到我的邮件服务,但它不起作用。如果有人能帮我修复我的代码,我将非常感激。那就是:将iCalendar事件附加到Grails中的邮件中

**这部分是我的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

这就是答案

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 protected] 
    subject "Subject" 
    body "Some text here" 
    attach "event.ics", "text/calendar", emailFile(**params**) 
} 
相关问题