Mail / FTP / Safari combo script?

I am experienced in programming with a few languages, but am completely new to AppleScript and am having trouble differentiating up from down.

I want a script to do the following:

  1. save unread message(s) in a given Mail mailbox… save them to a plaintext file.

  2. Upload the saved file to a webserver

  3. Call up a specific URL in Safari

  4. delete the uploaded file from the webserver

  5. delete the local copy of the saved file

  6. Mark the message(s) read

  7. exit

I would like to trigger the script to run via a rule in Mail.


So, can anyone give me any pointers, suggestions, hints at all? It would be greatly appreciated

Any suggestions at all?

I have figured out how to do everything EXCEPT:

What is the correct syntax for the following:

tell the application “Mail” to save unread messages in mailbox “yourname” as plaintext

???

PLEEEEEEASE!

ANY pointers, suggestions, hints, or outright answers will be so welcome and appreciated!!!