Applescript Help

D

Dave

I am having trouble downloading a message from my imap server using
applescript. I can not get the full source of a message when I have multiple
messages selected using the code below. I do get the dialog but the value of
theSource only contains the header information. I have set my imap options
to only download the headers.

I also tried with a delay after the download.

Subsequent runs of the script generates the same "downloading message"
dialog. This implies that the download did not work.

Any ideas?

tell application "Microsoft Entourage"

repeat with theMessage in selectedMessages

-- get the information from the message, and store it in variables
set theStatus to online status of theMessage

if theStatus is not fully downloaded then
display dialog "downloading message"
download theMessage
end if
set theSource to source of theMessage
set theSubject to subject of theMessage

end repeat
end tell
 
P

Paul Berkowitz

I have never had trouble with 'download'. However, I do recall that there
used to be a bug or two with 'online status' - it would give false results.
What happens if you leave out that check and simply 'download' without
checking if it's fully downloaded or not?

There's another possibility however. 'download' command does not have a
result. It's possible that the script goes straight on to the next commands
as soon as 'download' starts, without waiting for it to finish. If you click
"OK" in the dialog quickly, the message may not yet be downloaded. You can
add the following lines after the display dialog:

repeat while connection in progress
end repeat


Perhaps you might want to add the following lines _before_ the dialog, just
after 'download', to see what's going on:

repeat while not (connection in progress)
end repeat


to make sure the process has begun. But if it's really not downloading, it
will cycle there forever and you'll have to quit the script. Do it just as a
debug test, not in your final script.

--
Paul Berkowitz
MVP Entourage
Entourage FAQ Page: http://www.entourage.mvps.org/toc.html

Please "Reply To Newsgroup" to reply to this message. Emails will be
ignored.

PLEASE always state which version of Entourage you are using - 2001 or X.
It's often impossible to answer your questions otherwise.
 
D

Dave

Paul,

Thanks for the response. I added the following and it still does not work.
The result is a dialog with "downloaded message 0". The progress window do
not indicate a connection with my imap server when the download command is
executed.

Any other ideas?

set theStatus to online status of theMessage
if theStatus is not fully downloaded then
download theMessage
delay 1

set loopCount to 0
repeat while connection in progress
delay 1
set loopCount to loopCount + 1
end repeat

display dialog "downloaded message " & loopCount

end if

Dave
 
Top