I want to achieve the following:
Send an email with delayed_job containing:
- plain text
- html (will be displayed by regular customers who do not understand the built-in)
- "built-in" that is recognized by Outlook and Thunderbird (using Lightning).

- "regular" attachment (for # 2)
What works so far / what does'nt:
I can send an email via delayed_job with all parts, however:
- in Apple Mail 2 applications are displayed (instead of one):

(html displays ok)
- in Thunderbird (Lightning) I get an invitation, just like I want. But the alarm is not displayed.

- gsubs iCal, ATTENDEES. (. )
:
, : _job
, : content_type "multipart/mixed"
MIME-:
- /
- /
- /
- /HTML
- / ( : method = REQUEST)
- /
! .
:
: Rails 4.2 (attachments mail)
mailer.rb
def invitation_email(...)
subject = "I suck at email..."
attachments["invite.ics"] = { mime_type: "application/ics",
content: ical_attachment }
email = mail(from: me, to: you, subject: subject)
add_ical_part_to(email)
email
end
def add_ical_part_to(mail)
outlook_body = ical_attachment
mail.add_part(Mail::Part.new do
content_type "text/calendar; method=REQUEST"
body outlook_body
end)
end
, :
def ical_attachment
params_participant = {
"ROLE" => "REQ-PARTICIPANT",
"RSVP" => "FALSE",
"PARTSTAT" => "ACCEPTED"
}
params_invite = {
"CUTYPE" => 'INDIVIDUAL',
"ROLE" => "REQ-PARTICIPANT",
"PARTSTAT" => "NEEDS-ACTION",
"RSVP" => "TRUE"
}
cal = Icalendar::Calendar.new
event = Icalendar::Event.new
event.dtstart @party.from.to_datetime, { "VALUE" => "DATE" }
event.dtend @party.to.to_datetime, { "VALUE" => "DATE" }
event.summary @party.title
event.description @party.description
event.klass "PRIVATE"
event.organizer "cn=#{@user.name} #{@user.surname}:mailto:#{@user.email}"
event.alarm.trigger = "-PT5M"
@party.participations.each do |participation|
str = "cn=#{participation.user.name} #{participation.user.surname}:mailto:#{participation.user.email}"
event.add_attendee(str, params_participant)
end
@party.invitations.each do |invitee|
event.add_attendee("mailto:#{invitee.email}", params_invite)
end
cal.add_event(event)
cal.publish
cal.to_ical.gsub("ORGANIZER:", "ORGANIZER;").gsub("ACCEPTED:", "ACCEPTED;").gsub("TRUE:", "TRUE;").gsub("PUBLISH", "REQUEST")
end
!
: http://pastebin.com/patf05zd
, :