Yeahprettymuch
Yeahprettymuch

Reputation: 551

Generating and sending .ics file that automatically adds an event to a user's calendar

Right now we're using the icalendar gem to generate an ics file that we send via email.

While this does give the user a convenient "Add to my Calendar" button through email, it does not automatically add the event to the user's calendar too, making it so the user still has to do that manual step themselves.

Is there any way to make it so that the event is automatically added to the user's calendar? This has been hard to find a solution for.

def add_calendar_event
    @cal = Icalendar::Calendar.new
    @cal.event do |e|
      e.dtstart = start_time
      e.dtend = end_time
      e.summary = 'Organized Appointment'
      e.organizer = organizer_email
      e.attendee = user_email
     e.description = 'random string'
     e.status = 'CONFIRMED'
   end
   @ics_var = { mime_type: 'text/calendar; charset=UTF-8; method=REQUEST', content: @cal.to_ical }
 end

Upvotes: 0

Views: 2035

Answers (2)

Agaba Olivier
Agaba Olivier

Reputation: 1

There is a simple tool known as schedule importer. You can fill in multiple schedule events, dates, location and descriptions, then generate a .ics file that can be automatically opened across all calendar 📆 applications in multiple devices. Here's the link Schedule importer tool online

Upvotes: 0

Blair Anderson
Blair Anderson

Reputation: 20181

This requires a bit more understanding of calendars.

They use .ics files as a format for events, but calendars require users to add those events to their calendars.

For pure automation you must ask the user to "Authenticate with {Google/Outlook/ETC}" and provide "authorize read/write access to app".

Then you would be able to automatically add events to calendar.

Another way is to create a calendar RSS Feed and instruct the user to import your RSS feed into their calendars. You can make the URL unique to the user, requiring an API token or something so that its not purely public.

Upvotes: 1

Related Questions