diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index c8d6102c8c30725272181820d0c07b2d218990af..2b00e9b0826459faff13af12c0331e5742dd3eb2 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -4090,9 +4090,11 @@ static int forward_message(struct ast_channel *chan, char *context, struct vm_st
 
 		/* Forward VoiceMail */
 		long duration = 0;
+#ifdef IMAP_STORAGE
 		char *myserveremail = serveremail;
 		char buf[1024] = "";
 		int attach_user_voicemail = ast_test_flag((&globalflags), VM_ATTACH);
+#endif
  		RETRIEVE(dir, curmsg);
 		cmd = vm_forwardoptions(chan, sender, dir, curmsg, vmfmts, S_OR(context, "default"), record_gain, &duration, vms);
 		if (!cmd) {