Method: Mail::Message#body=
- Defined in:
- lib/mail/message.rb
#body=(value) ⇒ Object
Sets the body object of the message object.
Example:
mail.body = 'This is the body'
mail.body #=> #<Mail::Body:0x13919c @raw_source="This is the bo...
You can also reset the body of an Message object by setting body to nil
Example:
mail.body = 'this is the body'
mail.body.encoded #=> 'this is the body'
mail.body = nil
mail.body.encoded #=> ''
If you try and set the body of an email that is a multipart email, then instead of deleting all the parts of your email, mail will add a text/plain part to your email:
mail.add_file 'somefilename.png'
mail.parts.length #=> 1
mail.body = "This is a body"
mail.parts.length #=> 2
mail.parts.last.content_type.content_type #=> 'This is a body'
1237 1238 1239 |
# File 'lib/mail/message.rb', line 1237 def body=(value) body_lazy(value) end |