'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] = {'uid': uid, 'flags': flags, 'time': rtime, 'mtime': mtime, 'labels': labels}
    flags = ''.join(sorted(flags))
    labels = ',    '.join(sorted(labels))
    self.__sql_write('INSERT    INTO    status    (id,flags,mtime,labels)    VALUES    (?,?,?,?)', (uid, flags, mtime, labels))
    return uid
