Last updated at 4:46 am UTC on 25 January 2009
Squeak, and Celeste in particular, uses class MailMessage to store and access an Internet email message. Here are some of the handier methods it has:
- from: (class method) – parse a message from a string, and return a MailMessage object
- fieldNamed:ifAbsent: – look up a header field, e.g. the From line.
- fieldsNamed:ifAbsent: – look up all instances of a header field
- bodyText – return the body of the message as a Text
- body – return the body of the message as a MIMEDocument
- parts – return the parts
Note that header fields are returned as MIMEHeaderValue's, not as raw strings. This class is easy to use – just check out the code.
MailMessages may also be constrnucted in code, with methods like:
- empty (class method) – create an MailMessage with no headers and an empty body
- setField:toString: – modify a header field
- body: – set the body
- addAttachmentFrom:withName: – add an binary attachment
Here's a simple example:
setField: 'date' toString: MailMessage dateStampNow;
setField: 'from' toString: aFromString;
setField: 'to' toString: aToString;
setField: 'subject' toString: aSubjectString;
body: (MIMEDocument content: 'testing'))
Right now, the construction methods are limitted – there is just enough present to support Celeste composition windows.