'Writes a new message, with the specified uid.
See folder/Base for detail. Note that savemessage() does not
check against dryrun settings, so you need to ensure that
savemessage is never called in a dryrun mode.'

def savemessage(self, uid, content, flags, rtime, mtime=0, labels=set()):

    if (uid < 0):
        return uid
    if self.uidexists(uid):
        self.savemessageflags(uid, flags)
        return uid
    self.messagelist[uid] = self.msglist_item_initializer(uid)
    self.messagelist[uid]['flags'] = flags
    self.messagelist[uid]['time'] = rtime
    self.messagelist[uid]['mtime'] = mtime
    self.messagelist[uid]['labels'] = labels
    self.save()
    return uid
