Class RMail::Message

In: | lib/rmail/message.rb
Parent: | Object

The RMail::Message is an object representation of a standard Internet email message, including MIME multipart messages.

An RMail::Message object represents a message header (held in the contained RMail::Header object) and a message body. The message body may either be a single String for single part messages or an Array of RMail::Message objects for MIME multipart messages.

Methods

== add_part body body= decode each each_part header multipart? new part to_s

Attributes

epilogue | [RW] | Access the epilogue string for this message. The epilogue string is relevant only for multipart messages. It is the text that occurs after all parts of the message and is generally nil.
preamble | [RW] | Access the preamble string for this message. The preamble string is relevant only for multipart messages. It is the text that occurs just before the first part of the message, and is generally nil or simple English text describing the nature of the message.

Public Class methods

new()

Create a new, empty, RMail::Message.

Public Instance methods

==(other)

Test if this message is structured exactly the same as the other message. This is useful mainly for testing.

body()

Returns the body of the message as a String or Array.

If #multipart? returns true, it will be an array of RMail::Message objects. Otherwise it will be a String.

See also #header.

body=(s)

Sets the body of the message to the given value. It should either be a String or an Array of RMail:Message objects.

header()

Returns the RMail::Header object.

See also #body.

multipart?()

Return true if the message consists of multiple parts.

add_part(part)

Add a part to the message. After this message is called, the #multipart? method will return true and the #body method will #return an array of parts.

decode()

Decode the body of this message.

If the body of this message is encoded with `quoted-printable` or `base64`, this function will decode the data into its original form and return it as a String. If the body is not encoded, it is returned unaltered.

This only works when the message is not a multipart. The `Content-Transfer-Encoding:` header field is consulted to determine the encoding of the body part.

part(i)

Get the indicated part from a multipart message.

to_s()

Returns the entire message in a single string. This uses the RMail::Serialize class.

each_part() {|part| ...}

Return each part of this message

FIXME: not tested

each() {|line| ...}

Call the supplied block for each line of the message. Each line will contain a trailing newline (`\n`).