If you use FreePBX, the extension prefix to transfer to voicemail is derived from MySQL tables set by FreePBX directly. It does not care if you have 4 or 10 digit extensions. Run this:
/usr/local/fop2/autoconfig-buttons.sh
inspect the output from one SIP/xxx extension, you will see a header named "extenvoicemail". consider its value, this is a sample definition:
[SIP/1604]
type=extension
extension=1604
label=John
mailbox=1604@default
context=from-internal
queuechannel=Local/1604@from-queue/n|Penalty=0|MemberName=John|StateInterface=SIP/1604
customastdb=CF/1604
extenvoicemail=*1604@from-internal
queuecontext=from-queue
autoanswerheader=__SIPADDHEADER51=Call-Info=answer-after=0.001
How does extenvoicemail looks on your own config? Does it look correct? ( a prefix + extension number) ?