我一直在努力发送会议邀请作为附件以及电子邮件模板,以便将其添加到用户日历中,但邮件是作为约会发送的,而不是作为会议邀请发送。
即使在.ics文件中,也不会显示RSVP,组织者和与会者也不会收到任何邮件。
邮件程序
class MyMailer < ActionMailer::Base
default from: 'abc@gmail.com'
layout 'mailer'
def my_first_email(event_user)
@user = event_user
organizer_params = { "CUTYPE": "INDIVIDUAL",
"ROLE": "REQ-PARTICIPANT",
"PARTSTAT": "NEEDS-ACTION",
"RSVP": "TRUE",
"CN": "abc",
"X-NUM-GUESTS": "1" }
attendee_params = { "CUTYPE": "INDIVIDUAL",
"ROLE": "REQ-PARTICIPANT",
"PARTSTAT": "NEEDS-ACTION",
"RSVP": "TRUE",
"CN": "xyz",
"X-NUM-GUESTS": "0" }
@cal = Icalendar::Calendar.new
@cal.event do |e|
e.dtstart = Icalendar::Values::Date.new('20180606')
e.dtend = Icalendar::Values::Date.new('20180607')
e.summary = "Meeting with the man."
e.description = "Have a long lunch meeting and decide nothing..."
organizer_value = Icalendar::Values::CalAddress.new("MAILTO:abc@gmail.com", organizer_params)
attendee_value = Icalendar::Values::CalAddress.new("MAILTO:xyz@gmail.com", attendee_params)
e.organizer = organizer_value
e.attendee = attendee_value
e.alarm do |a|
a.action = "EMAIL"
a.description = "This is an event reminder" #email body (required)
a.summary = "Alarm notification" #email subject (required)
a.attendee = %w(mailto:xyz@gmail.com)
a.trigger = "-PT15M" #15 minutes before
end
e.status = 'CONFIRMED'
end
@cal.ip_method = "REQUEST"
mail.attachments['calendar_event.ics'] = { mime_type: 'text/calendar', method: 'REQUEST', charset: 'UTF-8', content: @cal.to_ical}
mail( to: 'abc@gmail.com', subject: 'Welcome to my website!')
end
end
及以下是显示的ical
BEGIN:VCALENDAR
VERSION:2.0
PRODID:icalendar-ruby
CALSCALE:GREGORIAN
METHOD:REQUEST
BEGIN:VEVENT
DTSTAMP:20180605T122806Z
UID:0150460f-5c41-4ab5-bfdf-b67d352e94de
DTSTART;VALUE=DATE:20180606
DTEND;VALUE=DATE:20180607
DESCRIPTION:Have a long lunch meeting and decide nothing...
ORGANIZER;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP
=TRUE;CN=abc;X-NUM-GUESTS=1:mailto:abc@gmail.com
SUMMARY:Meeting with the man.
ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=
TRUE;CN=xyz;X-NUM-GUESTS=0:mailto:xyz@gmail.com
BEGIN:VALARM
ACTION:EMAIL
TRIGGER:-PT15M
DESCRIPTION:This is an event reminder
SUMMARY:Alarm notification
ATTENDEE:mailto:xyz@gmail.com
END:VALARM
END:VEVENT
END:VCALENDAR