Ruby 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:[email protected] mailto:[email protected]) # one or more email recipients (required)
add_attendee "mailto:[email protected]"
remove_attendee "mailto:[email protected]"
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:[email protected]) # one or more email recipients (required)
trigger "-PT25M" # 25 minutes before
end
end
但是,我从未看到任何电子邮件发送到我的帐户...我什至尝试将开始时间硬编码为 Time.now,并在 0 分钟前发送它们,但没有运气...我是在做一些明显的事情吗错误的?
I'm trying to work out how to use the icalendar ruby gem, found at:
http://icalendar.rubyforge.org/
According to their tutorial, you do something like:
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:[email protected] mailto:[email protected]) # one or more email recipients (required)
add_attendee "mailto:[email protected]"
remove_attendee "mailto:[email protected]"
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
So, I am doing something similar in my code.
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:[email protected]) # one or more email recipients (required)
trigger "-PT25M" # 25 minutes before
end
end
However, I never see any e-mail sent to my account... I have even tried hard coding the start times to be Time.now, and sending them out 0 minutes before, but no luck... Am I doing something glaringly wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
iCalendar gem 不会处理通知发送 - 警报只是 ical 中的一个概念。您必须实现自己的服务,发送电子邮件通知并附加生成的数据。
The iCalendar gem will not handle notification sending - alarm is just an concept in for ical. You have to implement your own service which dispatches email notifications and attach the generated ical data.
http://icalendar.rubyforge.org/ 上的警报示例只是让 iCal/outlook 知道警报应该在事件上设置,并且应用程序(ical/outlook)从该点开始处理它。
与在 iCal 上创建事件并设置闹钟非常相似。
因此 iCalendar 不会发送通知,iCal/outlook 会发送通知。
以防万一其他人发现这个。
The alarm example on http://icalendar.rubyforge.org/ is just letting iCal/outlook know that an alarm should be set on an event and that application(ical/outlook) handles it from that point on.
Much the same as creating an event on iCal and setting an alarm.
So iCalendar won't send the notifications, iCal/outlook will.
Just in case anyone else finds this.