Summary:ASTERISK-14008: Attaching msg0001.WAV instead of msg0000.WAV
Reporter:Frederic Jean (makafre)Labels:
Date Opened:2009-04-23 09:25:51Date Closed:2011-06-07 14:01:07
Versions:Frequency of
Description:1) Clean the INBOX directory so no messages remain (using rm)
2) Make a call and leave a voicemail
3) Check the INBOX directory, msg0000.WAV is created
4) Produced e-mail tries to attach msg0001.WAV

I tried with 4 or 5 messages and it always look for an attachment
offset by 1, so it's never to be found. Here is my setup:


emailsubject=Message telephonique ${VM_MSGNUM} (boite ${VM_MAILBOX})

emailbody=\n\nBonjour ${VM_NAME},\n\nVous avez recu un message telephonique:\n\nDate:\t\t\t${VM_DATE}\nDuree:\t\t\t${VM_DUR}\nNumero:\t\t\t${VM_MSGNUM}\nBoite vocale:\t\t${VM_MAILBOX}\nDe:\t\t\t${VM_CALLERID}\n\n\t\t\t\t--Merci de votre attention!!\n

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


cat > /tmp/astmail.txt


Date: Wed, 22 Apr 2009 08:55:50 -0400
From: "asterisk" <Messagerie@cl-t069-240cl.privatedns.com>
To: "MaKaFre" <makafre@gmail.com>
Subject: =?ISO-8859-1?Q?Message_telephonique_1_=28boite_5143947865=29?=
Message-ID: <Asterisk-1-1422536047-5143947865-28731@cl-t069-240cl.privatedns.com>
X-Asterisk-CallerID: 5142335853
X-Asterisk-CallerIDName: Unknown Name
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="----voicemail_1514394786528731872539470"

This is a multi-part message in MIME format.

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

Bonjour MaKaFre,

Vous avez recu un message telephonique:

Date:                   Wednesday, April 22, 2009 at 08:55:50 AM
Duree:                  0:11
Numero:                 1
Boite vocale:           5143947865
De:                     "Unknown Name" <5142335853>

                               --Merci de votre attention!!

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

....[cut for clarity].....

[root@cl-t069-240cl INBOX]# ls -la
total 32
drwxr-xr-x 2 root root  4096 Apr 22 08:55 .
drwxr-xr-x 7 root root  4096 Apr 21 11:09 ..
-rw-r--r-- 1 root root   280 Apr 22 08:55 msg0000.txt
-rwxr-xr-x 1 root root 18650 Apr 22 08:55 msg0000.WAV

*** Changing make_email_file function from app_voicemail.c solved
the problem; it's just a matter of replacing "msgnum + 1" with "msgnum".

fprintf(p, "Content-Type: %s%s; name=\"msg%04d.%s\"" ENDL, ctype, format, msgnum + 1, format);
               fprintf(p, "Content-Transfer-Encoding: base64" ENDL);
               fprintf(p, "Content-Description: Voicemail sound attachment." ENDL);
               fprintf(p, "Content-Disposition: attachment; filename=\"msg%04d.%s\"" ENDL ENDL, msgnum + 1, format);

fprintf(p, "Content-Type: %s%s; name=\"msg%04d.%s\"" ENDL, ctype, format, msgnum, format);
               fprintf(p, "Content-Transfer-Encoding: base64" ENDL);
               fprintf(p, "Content-Description: Voicemail sound attachment." ENDL);
               fprintf(p, "Content-Disposition: attachment; filename=\"msg%04d.%s\"" ENDL ENDL, msgnum, format);

I dont really know the overall impact of this modification but for my particular case, the problem was solved.
Comments:By: Tilghman Lesher (tilghman) 2009-04-23 11:46:45

This is actually intentional.  Some people think that messages start with "1" instead of "0", so this change was made for that reason.  This is not a bug.