Launch script within Mail problems
Launch script within Mail problems
- Subject: Launch script within Mail problems
- From: Dan Doughtie <email@hidden>
- Date: Sat, 14 Feb 2004 10:47:21 -0500
The same basic script works perfectly with Pop accounts in Entourage except
when grabbing messages from an IMAP or Exchange account. In that regard I
have the same issue.
I have a Rule set up in MAIL that has two tasks:
ALL MESSAGES are
MOVED TO Mailbox/Folder "MNS"
Then this Applescript is launched (stripped down for simplicity)
tell application "Finder"
set myMNSDisk to name of startup disk
set myMNSDisk to myMNSDisk & ":Shared Items:Public:~TO MNS:"
end tell
global MyText
global mySubject
tell application "Mail"
set mymessages to every message in mailbox "MNS" --
repeat with x in mymessages
set myBravesText to ""
set mySubject to ""
set mySubject to subject of x
my replace_chars2("FW:", "")
set MyText to content of x as string
my replace_chars(ASCII character 10, ASCII character 13)
my replace_chars("''", "\"")
set my sendcat to "News"
set mySubject to ((myMNSDisk) as text) & ":" & mysendcat & ":" &
mySubject as string
my write_to_file(MyText, mySubject, true) --open mydisk
end repeat
end tell
on replace_chars(search_string, replacement_string)
set AppleScript's text item delimiters to the search_string
set the item_list to every text item of MyText
set AppleScript's text item delimiters to the replacement_string
set MyText to the item_list as string
set AppleScript's text item delimiters to ""
end replace_chars
on replace_chars2(search_string, replacement_string)
set AppleScript's text item delimiters to the search_string
set the item_list to every text item of mySubject
set AppleScript's text item delimiters to the replacement_string
set mySubject to the item_list as string
set AppleScript's text item delimiters to ""
end replace_chars2
--cleanup bill's copy separately so his email address won't be at the
bottom.
on write_to_file(MyText, mySubject, append_data)
try
set the mySubject to the mySubject as text
set the open_target_file to open for access file mySubject with
write permission
write MyText to the open_target_file starting at eof
close access the open_target_file
on error
try
close access file mySubject
end try
return false
end try
end write_to_file
***********
This works perfectly except that it never sees the message(s) that invoked
the script. I've tried putting in delays but all it does is delay moving the
messages. It's like the AppleScript launch start prior to the finish of the
move task.
So the next email in actually cleans and delivers the previous email. I
tried sending an auto email to the account to force it to send the next one
but no matter what I did conditionally it started a loop.
I've even created a folder action that mimics this script that basically
forces the script to run again and clear the messages and that didn't work
for some reason... nor running an On Idle app to run the script every
minute.
Could it be that it is a object description problem with Mailbox or Folder.
In Entourage it is a folder, in Mail it is a Mailbox BUT if the name is
wrong why does the script find previously deposited emails. I need a drink.
Any suggestions.
Dan Doughtie
Augsuta, GA
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.