1
votes

I'm trying to send an appointment from ruby (rails) to Microsoft Outlook 2013.
When I'm sending an ICS file in the attachment, user have to open the file manually.
Looking for a way to send normal meeting request (user won’t need to open ICS to accept it).

I read the tutorial: http://knaveofdiamonds.com/post/50689213/sending-outlook-appointments-with-ruby but it’s not working for me, user getting the following email:

--
Date: Tue, 27 May 2014 23:17:23 +0300
Message-ID: <[email protected]>
Mime-Version: 1.0
Content-Type: text/plain;
 charset=UTF-8
Content-Transfer-Encoding: base64
Content-Disposition: inline

QSBSdWJ5IGNyZWF0ZWQgYXBwb2ludG1lbnQ=

--
Date: Tue, 27 May 2014 23:17:23 +0300
Message-ID: <[email protected]>
Mime-Version: 1.0
Content-Type: text/calendar;
 charset=UTF-8;
 method=request;
 name=subject.ics
Content-Transfer-Encoding: quoted-printable
content-class: urn:content-classes:calendarmessage

BEGIN:VCALENDAR
VERSION:2.0
PRODID:icalendar-ruby
CALSCALE:GREGORIAN
BEGIN:VEVENT
DTSTAMP:20140527T201722Z
UID:abb15328-a6af-4c95-8e04-acdb9d6584e2
DTSTART:20140623T083000
DTEND:20140624T083000
CLASS:PRIVATE
DESCRIPTION:Have a long lunch meeting and decide nothing...
SUMMARY:Meeting with the man.
END:VEVENT
END:VCALENDAR

This is my ruby code

cal = Icalendar::Calendar.new
cal.event do |e|
  e.dtstart     = DateTime.civil(2014, 6, 23, 8, 30)
  e.dtend       = DateTime.civil(2014, 6, 24, 8, 30)
  e.summary     = "Meeting with the man."
  e.description = "Have a long lunch meeting and decide nothing..."
  e.ip_class    = "PRIVATE"
  e.uid         = SecureRandom.uuid
end

Mail.defaults do
  delivery_method :smtp, options
end

mail = Mail.new
mail.mime_version = "1.0"
mail.body = cal.to_ical
mail.from = '[email protected]'
mail.to = '[email protected]'
mail.subject = 'bla'
mail.content_type = "text/calendar"

mail.deliver

Any idea?

1

1 Answers

2
votes

You should not send an ICS file as an attachment. Your whole message must have the content type of text/calendar and it should have a single part - text/calendar:

Date: Tue, 27 May 2014 23:17:23 +0300
Message-ID: <[email protected]>
Mime-Version: 1.0
Content-Type: text/calendar;
 charset=UTF-8;
 method=request;
 name=subject.ics
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
content-class: urn:content-classes:calendarmessage

BEGIN:VCALENDAR
VERSION:2.0
PRODID:icalendar-ruby
CALSCALE:GREGORIAN
BEGIN:VEVENT
DTSTAMP:20140527T201722Z
UID:abb15328-a6af-4c95-8e04-acdb9d6584e2
DTSTART:20140623T083000
DTEND:20140624T083000
CLASS:PRIVATE
DESCRIPTION:Have a long lunch meeting and decide nothing...
SUMMARY:Meeting with the man.
END:VEVENT
END:VCALENDAR