advice:
if download() is called from within the mail function, it runs fine,
if download() is called from check_filename() function, it does not run.
do i have a filename in the wrong format?
using terms from application "Mail"
on perform mail action with messages theMessages
repeat with thisMail in theMessages
tell thisMail
set the_subject to get subject
set the_sender to get sender
set the_body to (source of thisMail as text)
end tell
-- display dialog the_body
end repeat
set the_info to the_body
set AppleScript's text item delimiters to {"**"}
set the_info to second text item of (the_info as string)
set AppleScript's text item delimiters to {"|"}
set the_name to first text item of (the_info as string)
set the_email to second text item of (the_info as string)
set the_image to third text item of (the_info as string)
set the_newimage to third text item of (the_info as string)
-- display dialog the_name & " " & the_image
-- download(the_image, the_newimage)
check_filename(the_image, the_newimage)
-- upload(the_image)
comments(the_name, the_email, the_image)
end perform mail action with messages
end using terms from
property the_path : "Alaska:Users:sl:Desktop:EH:"
on check_filename(the_image, the_newimage)
display dialog "checking"
set the_imagepath to the_path & the_image
tell application "Finder"
repeat
if not (file the_imagepath exists) then
display dialog "download"
download(the_image, the_newimage)
else
display dialog "else"
set AppleScript's text item delimiters to "."
set BaseFilename to text item 1 of the_image
set FileExt to text item 2 of the_image
set DateStamp to do shell script "date +%m%d%y" --You may want to remove '_%y'
set the_newimage to text BaseFilename & "_" & DateStamp & "." & FileExt
set the_imagepath to the_path & the_newimage
end if
end repeat
end tell
end check_filename