使用iCal4j库(Java-Spring)发送日历事件(邀请)

时间:2018-07-25 10:12:25

标签: java spring calendar google-calendar-api ical4j

这个问题与iCal4j库与Java(Spring)应用程序的集成有关。

用例- 在我的应用程序中,当用户从UI创建事件时,被邀请者应收到日历邀请,只需单击事件即可将其添加到其个人日历(Google日历,Outlook日历甚至Thundarbird日历)中。此外,活动组织者应收到同一事件的日历邀请。

关注- 与会者通过电子邮件以正确的格式(Google日历,Outlook和Thundarbird)接收创建的活动的日历邀请时,组织者会收到带有附件的空电子邮件(invite.ics)。请注意,这种担忧仅在Gmail邮件和Outlook邮件客户端中引起。在Thunderbird中,甚至组织者也收到完整的事件请求。 (请参阅随附的代码段和图片以进一步了解。)

请让我知道如何解决此问题或我可以用来完成此任务的任何替代库或解决方案。

谢谢。

StringBuffer buffer = sb.append( "BEGIN:VCALENDAR\n" +
     "PRODID:-//PROD_NAME//PROD_ORG//EN\n" +
     "VERSION:2.0\n" +
     "X-WR-RELCALID:"+calendarEmail.getxWrRelcalid()+"\n" +
     "METHOD:REQUEST\n" +
     "BEGIN:VEVENT\n" +
     calendarEmail.getAttendeeString() +
     calendarEmail.getOrganizerString() +
     "DTSTART:" + calendarEmail.getDtStart() + "\n" +
     calendarEmail.getRruleString() +
     "DTEND:" + calendarEmail.getDtEnd() + "\n" +
     "LOCATION:" + calendarEmail.getLocation() + "\n" +
     "TRANSP:OPAQUE\n" +
     "SEQUENCE:"+calendarEmail.getSequence()+"\n" +
     "UID:" + calendarEmail.getUid() + "\n" +
     "DTSTAMP:" + calendarEmail.getDtStamp() + "\n" +
     "STATUS:"+calendarEmail.getEventStatusString()+"\n" +
     "CATEGORIES:" + calendarEmail.getCategory() + "\n" +
     "DESCRIPTION:" + calendarEmail.getDescription() + "\n" +
     "SUMMARY:" + calendarEmail.getSummary() + "\n" +
     "PRIORITY:5\n" +
     "CLASS:" + calendarEmail.getPublicity() + "\n" +
     "BEGIN:VALARM\n" +
     "TRIGGER:" + calendarEmail.getAlarmTrigger() + "\n" +
     "ACTION:" + calendarEmail.getAlarmAction() + "\n" +
     "DESCRIPTION:Reminder\n" +
     "END:VALARM\n" +
     "END:VEVENT\n" +
     "END:VCALENDAR" );

Email received by the organizer who is using the Thunderbird mail client

Email received by the organizer who is using the Google mail client

Email received by an invitee who is using the Google mail client

1 个答案:

答案 0 :(得分:0)

我认为这更多是关于iCalendar规范如何工作的问题。具体来说,您可能要看一下:

https://tools.ietf.org/html/rfc5546#section-3.2.2

在您的情况下,您的程序代表组织者行事,因此我不确定您可以向组织者用户发送“请求”。

您可能需要向组织者用户发送“发布”方法:

https://tools.ietf.org/html/rfc5546#section-3.2.1

您可能还需要考虑Organizer属性上的SENT-BY参数,以指示Organizer用户未发送请求(除非您希望REPLYs返回到程序):

https://tools.ietf.org/html/rfc5545#section-3.2.18