PDA

View Full Version : Applescript problem


pmazer
2005-12-07, 22:45
set txt to ""
set filename to POSIX path of (path to desktop) & "email.txt"

tell application "Mail"
check for new mail
repeat with msg in messages in inbox
if id in msg is not equal to id in first message in inbox then
set txt to txt & "
###

"
end if
set txt to txt & "From: " & (sender in msg) & "
Subject: " & (subject in msg) & "

" & (content in msg)
end repeat
end tell

tell application "TextEdit"
set textfile to (make new document at beginning with properties {text:txt})
save textfile in filename
end tell

I'm working on an Applescript to output email to a text file, but I'm encountering a problem. Whenever this is run, instead of saving it to the Desktop, it saves it to the root directory as the file ":Users:username:Desktop:email.txt" instead of the file "email.txt" in my desktop. How do I fix this? Thanks!

drewprops
2005-12-08, 01:15
not being an Applescript guy I would experiment with writing out all of the variables to that text file just to find out all the values (like the variable 'filename' (shouldn't that file actually be called 'filepath'? Is that a reserved word?), then I would fiddle with the assignations of values to the variables to see what was printed on successive runs of the script... I would essentially be reverse engineering my own code to get my bearings. Ugly, eh?