I a using Rails 5 (but that should be irrelevant) and need to generate and send an email message that contains an ‘icalendar’ (ics) notification.
I discovered the gem icalendar
and am using that to generate the ‘.ics’
In my simple setup I created this method
def create_calendar_event
cal = Icalendar::Calendar.new
cal.event do |e|
e.dtstart = Icalendar::Values::Date.new('20160511')
e.dtend = Icalendar::Values::Date.new('20160511')
e.summary = "Summary"
e.description = "Description"
e.ip_class = "PRIVATE"
end
cal
end
And in app/mailers/user_mailer.rb
which is inherited from ApplicationMailer I have this call
def notification_email(user, ical, summary)
@user = user
mail.attachments['slackminder.ics'] = { mime_type: 'application/ics', content: ical.to_ical }
mail(to: @user.email, subject: "Slack [re]Minder for #{summary}" )
end
Armed with the appropriate mailer ‘views’ I do receive the email message but the attached ics is malformed in some way.
Are there some good tools for troubleshooting this?
Does anyone have experience with this to share and help me?