Method: Mail::Message#part

Defined in:
lib/mail/message.rb

#part(params = {}) {|new_part| ... } ⇒ Object

Allows you to add a part in block form to an existing mail message object

Example:

mail = Mail.new do
  part :content_type => "multipart/alternative", :content_disposition => "inline" do |p|
    p.part :content_type => "text/plain", :body => "test text\nline #2"
    p.part :content_type => "text/html", :body => "<b>test</b> HTML<br/>\nline #2"
  end
end

Yields:

  • (new_part)


1722
1723
1724
1725
1726
# File 'lib/mail/message.rb', line 1722

def part(params = {})
  new_part = Part.new(params)
  yield new_part if block_given?
  add_part(new_part)
end