'Delete a folder on the IMAP server.'

def deletefolder(self, foldername):

    imapobj = self.imapserver.acquireconnection()
    try:
        result = imapobj.delete(foldername)
        if (result[0] != 'OK'):
            raise OfflineImapError(("Folder    '%s'[%s]    could    not    be    deleted.    Server    responded:    %s" % (foldername, self, str(result))), OfflineImapError.ERROR.FOLDER)
    finally:
        self.imapserver.releaseconnection(imapobj)
