From ca2cfc8e476b2c3c525ec3c030b47008c1bd6fb4 Mon Sep 17 00:00:00 2001 From: Mark Michelson <mmichelson@digium.com> Date: Wed, 20 Feb 2008 00:49:38 +0000 Subject: [PATCH] When using IMAP storage, if the folder you attempt to save to does not exist, create it first. (closes issue #12032) Reported by: jaroth Patches: createfolder.patch uploaded by jaroth (license 50) Tested by: jaroth git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@103833 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- apps/app_voicemail.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index 987d66675f..ddf2431b0e 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -3474,11 +3474,20 @@ static int save_to_folder(struct ast_vm_user *vmu, struct vm_state *vms, int msg /* simple. huh? */ long res; char sequence[10]; + char mailbox[256]; /* if save to Old folder, just leave in INBOX */ if (box == 1) return 10; /* get the real IMAP message number for this message */ snprintf(sequence, sizeof(sequence), "%ld", vms->msgArray[msg]); + /* Create the folder if it don't exist */ + imap_mailbox_name(mailbox, sizeof(mailbox), vms, box, 1); /* Get the full mailbox name */ + ast_debug(5, "Checking if folder exists: %s\n",mailbox); + if (mail_create(vms->mailstream, mailbox) == NIL) + ast_debug(5, "Folder exists.\n"); + else + ast_log(LOG_NOTICE, "Folder %s created!\n",mbox(box)); + ast_debug(3, "Copying sequence %s to mailbox %s\n", sequence, mbox(box)); res = mail_copy(vms->mailstream, sequence, (char *)mbox(box)); if (res == 1) return 0; @@ -9454,6 +9463,7 @@ void mm_flags(MAILSTREAM * stream, unsigned long number) void mm_notify(MAILSTREAM * stream, char *string, long errflg) { + ast_debug(5, "Entering NOTIFY callback, errflag is %ld, string is %s\n", errflg, string); mm_log (string, errflg); } -- GitLab