Ruby ICalendar Gem:如何让电子邮件提醒工作

时间:2010-04-29 22:26:19

标签: ruby email icalendar gem

我正在尝试研究如何使用icalendar ruby​​ gem,发现于:

http://icalendar.rubyforge.org/

根据他们的教程,您可以执行以下操作:

  cal.event.do
# ...other event properties
alarm do
  action        "EMAIL"
  description   "This is an event reminder" # email body (required)
  summary       "Alarm notification"        # email subject (required)
  attendees     %w(mailto:me@my-domain.com mailto:me-too@my-domain.com) # one or more email recipients (required)
  add_attendee  "mailto:me-three@my-domain.com"
  remove_attendee "mailto:me@my-domain.com"
  trigger       "-PT15M" # 15 minutes before
  add_attach    "ftp://host.com/novo-procs/felizano.exe", {"FMTTYPE" => "application/binary"} # email attachments (optional)
end

alarm do
  action        "DISPLAY" # This line isn't necessary, it's the default
  summary       "Alarm notification"
  trigger       "-P1DT0H0M0S" # 1 day before
end

alarm do
  action        "AUDIO"
  trigger       "-PT15M"
  add_attach    "Basso", {"VALUE" => ["URI"]}  # only one attach allowed (optional)
end

所以,我在我的代码中做了类似的事情。

  def schedule_event
    puts "Scheduling an event for " + self.title + " at " + self.start_time
      start = self.start_time
      endt = self.start_time
      title = self.title
      desc = self.description
      chan = self.channel.name
      # Create a calendar with an event (standard method)
       cal = Calendar.new
      cal.event do
        dtstart       Program.convertToDate(start)
        dtend         Program.convertToDate(endt)
        summary     "Want to watch" + title + "on: " + chan + " at: " + start
        description  desc
        klass       "PRIVATE"
        alarm do
          action        "EMAIL"
          description   desc # email body (required)
          summary       "Want to watch" + title + "on: " + chan + " at: " + start     # email subject (required)
          attendees     %w(mailto:gtg287y@gmail.com) # one or more email recipients (required)
          trigger       "-PT25M" # 25 minutes before
        end

      end

但是,我从未看到任何电子邮件发送到我的帐户...我甚至尝试将开始时间硬编码为Time.now,并在0分钟前发送出去,但没有运气......我是做一些明显错误的事情?

2 个答案:

答案 0 :(得分:2)

iCalendar gem不会处理通知发送 - 闹钟只是一个概念。您必须实现自己的服务,该服务会分派电子邮件通知并附加生成的数据。

答案 1 :(得分:1)

http://icalendar.rubyforge.org/上的警报示例只是让iCal / outlook知道应该在事件上设置警报,并且该应用程序(ical / outlook)从该点开始处理它。

与在iCal上创建活动并设置闹钟非常相似。

因此iCalendar不会发送通知,iCal / outlook会。

以防其他人发现此事。