Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Calendar events (iCalendar vEvent) #138

Closed
sven-geisenhainer opened this issue Apr 25, 2018 · 7 comments
Closed

Add support for Calendar events (iCalendar vEvent) #138

sven-geisenhainer opened this issue Apr 25, 2018 · 7 comments

Comments

@sven-geisenhainer
Copy link

sven-geisenhainer commented Apr 25, 2018

Hi and thanks a lot for this great library!

My feature request: I would like to use Simple Java Mail to send calendar invitations, which have to smoothly integrate with Gmail/Google calendar and MS Outlook but should also get properly displayed in any ordinary client. This means I have to create multipart/alternative messages consisting of 3! alternatives: text/plain, text/html and text/calendar - at least MS Outlook is sending such invitations. Simply adding the ICS as attachment does not work with Outlook.

I found no way how to do this with Simple Java Mail, e.g. there is no setTextVCalendar() or addCustomText(String text, String mimeType).

What do you think?

@bbottema
Copy link
Owner

Hi @sven-mvolution, that's a good point! I will think about a proper solution.

@bbottema bbottema added this to the 6.0.0 milestone May 24, 2018
@bbottema
Copy link
Owner

bbottema commented Jun 1, 2018

I've been trying to create a MimeMessage by hand with an ical event in it using ical4j, but I've been unable to get gMail or Outlook to cooperate with me. It keeps seeing it as a simple attachment.

I'll keep playing around.

@sven-geisenhainer
Copy link
Author

Hi @bbottema - thanks for further investigating and considering this a useful enhancement!
Meanwhile I've locally changed your lib to suit my needs as follows - but of course still waiting for the "official" support ;)

  • Add support for a optional text/calendar alternative
  • Use 2051 test port and made unit test work
    See the attached patch file (diff against 5.0.3)
    calendar-alternative.patch.txt

@bbottema
Copy link
Owner

bbottema commented Jun 1, 2018

Some how Simple Java Mail manages the bodyparts better than when I do it manually :D

It works in Outlook 365 for me, but gMail still refused and only displays it as an attachment. I wonder if it even still works at all in gMail.

@bbottema bbottema changed the title Create multipart/alternative message consisting of 3 (or more) alternatives Add support for Calendar events (iCalendar vEvent) Jun 1, 2018
bbottema added a commit that referenced this issue Jun 1, 2018
bbottema added a commit that referenced this issue Jun 1, 2018
@bbottema
Copy link
Owner

bbottema commented Jun 1, 2018

Implemented for the 6.0.0 release.

Usage is simple:

// Create a Calendar with something like ical4j
Calendar icsCalendar = new Calendar();
icsCalendar.getProperties().add(new ProdId("-//Events Calendar//iCal4j 1.0//EN"));
icsCalendar.getProperties().add(Version.VERSION_2_0);

(..) // add attendees, organizer, end/start date and whatever else you need

// Produce calendar string
ByteArrayOutputStream bOutStream = new ByteArrayOutputStream();
new CalendarOutputter().output(icsCalendar, bOutStream);
String yourICalEventString = bOutStream.toString("UTF-8")

// Let Simple Java Mail handle the rest
currentEmailBuilder
    .withCalendarText(CalendarMethod.REQUEST, yourICalEventString)

Thanks for the help @sven-mvolution!

@bbottema bbottema closed this as completed Jun 1, 2018
bbottema added a commit that referenced this issue Jun 1, 2018
@bbottema bbottema added this to Done in Version 6.0.0 Aug 1, 2018
@bbottema
Copy link
Owner

Released in 6.0.0-rc1.

@bbottema
Copy link
Owner

6.0.0 has released as well, finally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Version 6.0.0
  
Done
Development

No branches or pull requests

2 participants