Method: Mail::Message#add_to_body
- Defined in:
- app/models/post.rb
#add_to_body(text_to_add) ⇒ Object
This method adds the given string to all plain text parts of the message. For multipart messages, this simply adds a part containing the text_to_add. This is used for email footers.
Attention: Multipart emails may have a tree structure, i.e. a part may contain several other parts. Therefore, this method calls itself recursively.
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'app/models/post.rb', line 174 def add_to_body( text_to_add ) CharlockHolmes require 'charlock_holmes/string' if self.multipart? # Simply add another part. # According to the documentation, this call will add another part # rather than wiping all. self.body = text_to_add else # plain text parts if self.content_type == nil || self.content_type.include?('text/plain') self.body = self.body_in_utf8 + text_to_add.encode('UTF-8') end end return self end |