'Convert the filename, content, mimetype triple into a MIME attachment
object.'

def _create_attachment(self, filename, content, mimetype=None):

    attachment = self._create_mime_attachment(content, mimetype)
    if filename:
        try:
            filename.encode('ascii')
        except UnicodeEncodeError:
            filename = ('utf-8', '', filename)
        attachment.add_header('Content-Disposition', 'attachment', filename=filename)
    return attachment
