2016-07-29 63 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**) 
}