I'm trying to copy all the attachments that I received from a certain sender (scanner) to a folder. I'm using Outlook and I've tried to write a script to do the job. It fails on saving the file with error code:
error "Microsoft Outlook got an error: Parameter error." number -50
Unfortunately I've not been able to figure out a) what that error means, and b) how to make the script work. Any help is welcome.
This is my script:
set saveToFolder to (choose folder with prompt "Choose the destination folder") as string
set ctr to 0
tell application "Microsoft Outlook"
set srcFolder to mail folder "inbox" of exchange account "FOO"
set selectedMessages to messages of srcFolder
repeat with msg in selectedMessages
set ctr to ctr + 1
set msgsender to the sender of msg
set senderaddress to the address of msgsender
if "[email protected]" = senderaddress then
set attFiles to attachments of msg
repeat with f in attFiles
set attName to (get the name of f)
log attName
set saveAsName to saveToFolder & attName
log saveAsName
save f in POSIX file saveAsName
end repeat
end if
end repeat
end tell
display dialog "" & ctr & " messages were processed" buttons {"OK"} default button 1
return ctr