Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


Share this Page URL
Help

MIME and Email Format Handling > Creating Messages - Pg. 546

MIMEAudio into physical lines of no more than maxheaderlen characters, for readability. To use g , just call it: g(m, unixfrom=False) This emits m in text form to outfp , like outfp .write( m .as_string( unixfrom )) . Creating Messages Package email supplies modules with names starting with ' MIME ', each module sup- plying a subclass of Message named like the module. These classes make it easier to create Message instances of various MIME types. The MIME classes are as follows. MIMEAudio class MIMEAudio(_audiodata,_subtype=None,_encoder=None,**_params) _audiodata is a byte string of audio data to pack in a message of MIME type ' audio/ _subtype '. When _subtype is None , _audiodata must be parseable by standard Python module sndhdr to determine the subtype; otherwise MIMEAudio raises a TypeError . When _encoder is None , MIMEAudio encodes data as Base 64, which is generally optimal. Other- wise, _encoder must be callable with one parameter m , the message being constructed;