2016-07-29 3 views
0

Grails 3.x、特にメールとiCalendarプラグインで作業していましたが、メールサービスにiCalendarイベントを添付しようとしましたが動作しませんでした。誰かが私のコードを修正する手助けをすることができれば、とても感謝しています。ここでは、次のとおりです。Grailsのメールに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と電子メールの送信の両方がにあります同じサービスクラス。

youtサポートに感謝します。 :)

答えて

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**) 
} 
です
関連する問題