Voicemail attachments using offset MSGxxxx index

I am using 1.4.21.1 and trying to send voicemails with attachments;
my problem is that the e-mail build-up tries to include the wrong filename.

E.g. Asterisk will write msg0000.wav but it will later try to attach msg0001.wav when sending the e-mail.

It seems to be always offset by one. I tried to clear the directory from
all files and tried again but I get the above result. The filename always
follow the same value as of ${VM_MSGNUM} but this value starts
at xxx1 while filename indexes start at xxx0.

Here is what I do to check it out:

voicmail.conf

mailcmd=nice -n 19 /etc/asterisk/bin/sendvoicemail.sh

sendvoicemail.sh

#!/bin/sh

cat > /tmp/astmail

/tmp/astmail

Date: Tue, 21 Apr 2009 17:31:16 -0400
From: “asterisk” xxxx@cl-t069-240cl.privatedns.com
To: “xxxx” xxxxx@gmail.com
Subject: =?ISO-8859-1?Q?Message_telephonique_3_=28boite_5143947865=29?=
Message-ID: Asterisk-3-349045189-5143947865-25281@cl-t069-240cl.privatedns.com
X-Asterisk-CallerID: 5142335853
X-Asterisk-CallerIDName: Unknown Name
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="----voicemail_3514394786525281759823288"

This is a multi-part message in MIME format.

------voicemail_3514394786525281759823288
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit

Bonjour XXXXXXXXXXXX,

Vous avez recu un message telephonique:

Date: Tuesday, April 21, 2009 at 05:31:16 PM
Duree: 0:09
Numero: 3
Boite vocale: 5143947865
De: “Unknown Name” <5142335853>

                            --Merci de votre attention!!

------voicemail_3514394786525281759823288
Content-Type: audio/x-WAV; name="msg0001.WAV"
Content-Transfer-Encoding: base64
Content-Description: Voicemail sound attachment.
Content-Disposition: attachment; filename=“msg0001.WAV”

UklGRiw/AABXQVZFZm10IBQAAAAxAAEAQB8AAFkGAABBAAAAAgBAAWZhY3QEAAAAADYBAGRh
dGH4PgAAqQpbRoACYOO4jeS2QmAjR27cSAVgHMdxHLdkgBu5jSRpfm/dKXcGSI4kSXKoA7hx
5MaNdgK2kds4cqkGOJIbN27lKNMhI0aAIzmSHJkKYCPJjeTWS2AcSW7jNk2AJMltHHeGEyFu…

…[cut]…