Class: RMail::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/autobuild/mail_reporter.rb

Instance Method Summary collapse

Instance Method Details

#add_file(name, path, content_type = 'text/plain') ⇒ Object

Attachs a file to a message



98
99
100
101
102
103
104
105
106
107
# File 'lib/autobuild/mail_reporter.rb', line 98

def add_file(name, path, content_type = 'text/plain')
    part = RMail::Message.new
    part.header.set('Content-Type', content_type)
    part.header.set('Content-Disposition', 'attachment', 'filename' => name)
    part.body = ''
    File.open(path) do |file|
        part.body << file.readlines.join("")
    end
    add_part(part)
end