-- Get the attachment(s) from the message
set tempFolderName to (tempFolder as string)
set minutesFiles to {}
try
set theAttachments to (get every mail attachment of theMessage)
on error
set theAttachments to {}
end try
repeat with anAttachment in theAttachments
try
if name of anAttachment ends with ".pdf" then
set fileName to name of anAttachment
tell zbaLib
set fileName to (changeSubstrings of fileName from ":" into "-")
set fileName to (changeSubstrings of fileName from "/" into "-")
end tell
set fileName to tempFolderName & fileName
display dialog fileName
save anAttachment in file fileName
tell application "Finder" to set end of minutesFiles to (file fileName)
end if
on error the error_message number the error_number
display dialog "Error saving attachment " & (name of anAttachment) & " to " & tempFolderName & ": " & the error_number & ". " & the error_message buttons {"OK"} default button 1
end try
end repeat
The first Display Dialog shows the fileName string for the save attachment command: