What libraries exist for creating raw multipart emails?
Python has modules both for creating and sending emails in the standard library. Don't know about Java or Ruby. For generating HTML I'd use some HTML template language. There are tons of them for Python. Pick one you like.
I would like to ideally set up a user interface for designing emails that include text, html, and images, and would like this interface to output the raw encoded email so I can then pipe it to my mail application, save it in a database, etc..  
Are there any libraries that I could look at for generating raw emails, and/or the necessary HTML?
For example:  You can create a document in MS Word (interface) and merge it with outlook to send.   Ideally I'd like a Jquery based library that would let me visually create the mail, and output the result as a long string.   
However, even any server-based libraries in any languages would be helpful:  Javascript, Ruby, Python, Java, etc..
I think what I'm looking for is a mail generation library (or as mentioned in the answer below, a mime-generation framework
EDIT:  I know this question is pretty general.. If it can be rephrased better let me know.  If its like asking for a "Facebook", and naive and unrealizable, let me know.  Useless comments that don't add anything not needed though