# File lib/mailfactory.rb, line 321
  def body_to_s()
    body = Array.new()
    
    # simple message with one part
    if(!multipart?())
      return(@text)
    else
      body << "This is a multi-part message in MIME format.\r\n\r\n--#{@attachmentboundary}\r\nContent-Type: multipart/alternative; boundary=\"#{@bodyboundary}\""
      
      if(@attachments.length > 0)
        # text part
        body << "#{buildbodyboundary("text/plain; charset=#{@charset}; format=flowed", 'quoted-printable')}\r\n\r\n#{quote_if_necessary(@text, @charset)}"
        
        # html part if one is provided
        if @html
          body << "#{buildbodyboundary("text/html; charset=#{@charset}", 'quoted-printable')}\r\n\r\n#{quote_if_necessary(@html, @charset)}"
        end
        
        body << "--#{@bodyboundary}--"
        
        # and, the attachments
        if(@attachments.length > 0)
          @attachments.each() { |attachment|
            body << "#{buildattachmentboundary(attachment)}\r\n\r\n#{attachment['attachment']}"
          }
          body << "\r\n--#{@attachmentboundary}--"
        end
      else
        # text part
        body << "#{buildbodyboundary("text/plain; charset=#{@charset}; format=flowed", 'quoted-printable')}\r\n\r\n#{quote_if_necessary(@text, @charset)}"
        
        # html part
        body << "#{buildbodyboundary("text/html; charset=#{@charset}", 'quoted-printable')}\r\n\r\n#{quote_if_necessary(@html, @charset)}"
        
        body << "--#{@bodyboundary}--"
      end
      
      return(body.join("\r\n\r\n"))
    end
  end