Fix imap insert multipart detection

The current imap adapter does not detect some messages with attachments as multipart. This change fixes this and also avoids a type error when setting attachment mime types as None