Can't save mail attachment

The error is not always the same but here goes : the saving code is :

				repeat with anAttachment in attachmentsFiles
					set filename to name of anAttachment
					set oldDelims to my text item delimiters
					set my text item delimiters to "."
					set fileExtension to last text item of filename
					set my text item delimiters to oldDelims
					set attachId to id of anAttachment
					set savetoFilePath to backupDirNonPOSIX & ":tmp:" & attachId & "_" & filename
					try
						save anAttachment in savetoFilePath
					end try
				end repeat

I get the error -1703 which has the string “Mail got an error : Some data was the wrong type.”
How can I get around this ?
I have seen that save has an argument that can be the file type, but I don’t know what I can pass there. I tried the file extension.
Thanks,
Regards