我正在使用javax.mail.internet
和发送电子邮件Biweekly
,这封电子邮件有附件谷歌会议邀请。电子邮件已发送,并且还附有邀请(会议也出现在谷歌日历中)。但问题是在事件开始之前没有发送提醒(警报)电子邮件。我正在尝试在活动开始前 15 分钟发送提醒电子邮件。这是我的代码:
private String generateICalData(AddCalendarEventDto addCalendarEventDto, String fromEmailName) {
ICalendar ical = new ICalendar();
ical.addProperty(new Method(Method.REQUEST));
VEvent event = new VEvent();
event.setSummary("invite summary");
event.setDescription("Please use this Zoom link: " + addCalendarEventDto.getMeetingLink());
event.setLocation("Zoom");
event.setDateStart(addCalendarEventDto.getDateStart());
event.setDateEnd(addCalendarEventDto.getDateEnd());
event.setDuration(new Duration.Builder()
.minutes(addCalendarEventDto.getDurationMinutes())
.build());
String eventUid = addCalendarEventDto.getEventUid();
if(eventUid != null && !"".equals(eventUid)){
event.setUid(eventUid);
event.setSequence(2);
}
event.setRecurrenceRule(new Recurrence.Builder(Frequency.WEEKLY).count(5).build());
event.setOrganizer(new Organizer(fromEmailName, USERNAME));
Attendee attendee = new Attendee(addCalendarEventDto.getMemberName(), addCalendarEventDto.getToEmail());
attendee.setParticipationLevel(ParticipationLevel.REQUIRED);
Duration reminder = Duration.builder().prior(true).minutes(15).build();
Trigger trigger = new Trigger(reminder, Related.START);
//Date date = new Date(System.currentTimeMillis() + 4*60*1000L);
//Trigger trigger = new Trigger(date);
String subject = "Reminder: Meeting at 1pm";
String body = "Team,\n\nThe team meeting scheduled for 1pm is about to start. Snacks will be served!\n\nThanks,\nJohn";
VAlarm valarm = VAlarm.email(trigger, subject, body, Arrays.asList(addCalendarEventDto.getToEmail(), "test1@gmail.com", "test2@gmail.com"));
event.addAlarm(valarm);
ical.addEvent(event);
return Biweekly.write(ical).go();
}
我也尝试了注释部分来创建Trigger
对象,但结果是一样的。我的代码有问题还是应该是什么问题?
我希望在活动开始前 15 分钟发送带有定义文本的提醒电子邮件。在这种情况下,我将提醒电子邮件设置为在发送邀请后 2 分钟发送以进行测试,但它不起作用。