Missing template notification_mailer/meeting_request_with_calendar with {:locale=>[:en], :formats=>[:ics], :handlers=>[:erb, :builder, :coffee]}

StackOverflow https://stackoverflow.com/questions/20897051

Question

I saw this code for sending a calendar invite mail. But, it gives following exception when it runs:

Missing template notification_mailer/meeting_request_with_calendar with {:locale=>[:en], :formats=>[:ics], :handlers=>[:erb, :builder, :coffee]}

    class MeetingNotification < ActionMailer::Base   # include Icalendar   def meeting_request_with_calendar
         mail(:to => "ashi_12@gmail.com", :subject => "iCalendar",
                      :from => "tester@gmail.com") do |format|
           format.ics {
           ical = Icalendar::Calendar.new
           e = Icalendar::Event.new
           e.start = DateTime.now.utc
           e.start.icalendar_tzid="UTC" # set timezone as "UTC"
           e.end = (DateTime.now + 1.day).utc
           e.end.icalendar_tzid="UTC"
           e.organizer "tester@gmail.com"
           e.uid "MeetingRequest"
           e.summary "Scrum Meeting"
           e.description <<-EOF
             Venue: Office
             Date: 16 August 2013
             Time: 10 am
           EOF
           ical.add_event(e)
           ical.publish
           ical.to_ical
           render :text => ical, :layout => false
          }
        end
   end
end
Was it helpful?

Solution

I am pretty sure you do not want to sent a ics formatted mail. You want to sent a mail in html format that has an ics attached. Something like:

def send_ics(user, event)
  mail.attachments['example.ics'] = { :mime_type => 'text/calendar',
                                      :content => generate_ics(event) }
  mail(:to => user.email, :subject => "iCalendar", :from => "tester@gmail.com")
end

private 
def generate_ics(event)
  ical = Icalendar::Calendar.new
  ...
  ical.to_ical
end

OTHER TIPS

The framework is looking for a template (like a meeting_request_with_calendar.erb file) in app/views/notification_mailer directory. It is expecting the template to be named meeting_request_with_calendar because that is the name of your method. The template is expected to format the email content.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top