Index: apps/app_voicemail.c =================================================================== --- apps/app_voicemail.c (revision 75656) +++ apps/app_voicemail.c (working copy) @@ -3135,6 +3135,13 @@ ast_unlock_path(dir); #ifndef IMAP_STORAGE + /* We must store the file first, before copying the message, because + * ODBC storage does the entire copy with SQL. + */ + if (ast_fileexists(fn, NULL, NULL) > 0) { + STORE(dir, vmu->mailbox, vmu->context, msgnum, chan, vmu, fmt, duration, vms); + } + /* Are there to be more recipients of this message? */ while (tmpptr) { struct ast_vm_user recipu, *recip; @@ -3152,8 +3159,8 @@ } } #endif + /* Notification and disposal needs to happen after the copy, though. */ if (ast_fileexists(fn, NULL, NULL)) { - STORE(dir, vmu->mailbox, vmu->context, msgnum, chan, vmu, fmt, duration, vms); notify_new_message(chan, vmu, msgnum, duration, fmt, S_OR(chan->cid.cid_num, NULL), S_OR(chan->cid.cid_name, NULL)); DISPOSE(dir, msgnum); }