Index: apps/app_voicemail.c =================================================================== --- apps/app_voicemail.c (revision 312284) +++ apps/app_voicemail.c (working copy) @@ -4534,12 +4534,10 @@ ast_unlock_path(dir); inprocess_count(vmu->mailbox, vmu->context, -1); } else { - for (;;) { - make_file(fn, sizeof(fn), dir, msgnum); - if (!EXISTS(dir, msgnum, fn, NULL)) - break; - msgnum++; - } +#ifndef IMAP_STORAGE + msgnum = last_message_index(vmu, dir) + 1; +#endif + make_file(fn, sizeof(fn), dir, msgnum); /* assign a variable with the name of the voicemail file */ #ifndef IMAP_STORAGE