Accessors and helpers that ActionMailer::Base and ActionMailer::Part have in common. Using these helpers you can easily add subparts or attachments to your message:

  def my_mail_message(...)
    ...
    part "text/plain" do |p|
      p.body "hello, world"
      p.transfer_encoding "base64"
    end

    attachment "image/jpg" do |a|
      a.body = File.read("hello.jpg")
      a.filename = "hello.jpg"
    end
  end
Methods
Attributes
[R] parts The list of subparts of this container
Public Instance methods
attachment(params, &block)

Add an attachment to a multipart message. This is simply a part with the content-disposition set to "attachment".

    # File lib/action_mailer/part_container.rb, line 34
34:     def attachment(params, &block)
35:       params = { :content_type => params } if String === params
36:       params = { :disposition => "attachment",
37:                  :transfer_encoding => "base64" }.merge(params)
38:       part(params, &block)
39:     end
part(params) {|part if block_given?| ...}

Add a part to a multipart message, with the given content-type. The part itself is yielded to the block so that other properties (charset, body, headers, etc.) can be set on it.

    # File lib/action_mailer/part_container.rb, line 25
25:     def part(params)
26:       params = {:content_type => params} if String === params
27:       part = Part.new(params)
28:       yield part if block_given?
29:       @parts << part
30:     end