I am trying to write a script that will parse a paypal email. The problem is that only the first two sections work. Here is the script I have written:
set theFile to (choose file with prompt “Select a file to read:” of type {“TEXT”})
open for access theFile
set fileContents to (read theFile)
close access theFile
set oldDelimiters to AppleScript’s text item delimiters – always preserve original delimiters
set AppleScript’s text item delimiters to {“mailto:”}
set parseString to text items of fileContents
set parseString to item 2 of parseString
set AppleScript’s text item delimiters to {“)”}
set parseString to text items of parseString
set emailAddress to item 1 of parseString
display dialog emailAddress
set AppleScript’s text item delimiters to {“$”}
set parseString to text items of fileContents
set parseString to item 2 of parseString
set AppleScript’s text item delimiters to {" "}
set parseString to text items of parseString
set payment to item 1 of parseString
display dialog payment
set AppleScript’s text item delimiters to {“Item:”}
set parseString to text items of fileContents
display dialog item 1 of parseString
set parseString to item 2 of parseString
set AppleScript’s text item delimiters to {“!”}
set parseString to text items of parseString
set itemDescription to item 1 of parseString
display dialog itemDescription
set AppleScript’s text item delimiters to oldDelimiters – always restore original delimiters
The first two sections work but the third errors with “Can’t get item 2 of " …lists the entire text…”
The really weird thing is that if I copy and paste the text into another script editor window and try to run it, all three sections don’t work.
Any help would be appreciated.
Carey