class Mail::Message

def add_file(values)

See also #attachments

m.parts.last.content_type.content_type #=> 'image/png'
m.parts.first.content_type.content_type #=> 'text/plain'
m.multipart? #=> true
m.add_file('/path/to/filename.png')
m.multipart? #=> false
end
body 'this is some text'
m = Mail.new do

Example:

plain part.
to a MIME multipart email, moving whatever plain text body you had into its own text
Note also that if you add a file to an existing message, Mail will convert that message

m.add_file(:filename => 'filename.png', :content => File.read('/path/to/file.jpg'))
m = Mail.new

m.add_file('/path/to/filename.png')
m = Mail.new

Example:

can pass in the filename as a string, and pass in the file content as a blob.
get the filename from the path you pass in and guess the MIME media type, or you
just pass in the absolute path to the file you want and Mail will read the file,
Adds a file to the message. You have two options with this method, you can
def add_file(values)
  convert_to_multipart unless self.multipart? || Utilities.blank?(self.body.decoded)
  add_multipart_mixed_header
  if values.is_a?(String)
    basename = File.basename(values)
    filedata = File.open(values, 'rb') { |f| f.read }
  else
    basename = values[:filename]
    filedata = values
  end
  self.attachments[basename] = filedata
end