Here is my script. What I want to do is to export the fields as tab delimted and save it either in text edit (preferred) or excel
set Ret to {ASCII character 13, ASCII character 10, (ASCII character 10) & (ASCII character 13)}
set Mat to {"Wood: ", "Chain Link: ", "Steel: ", "Aluminum: ", "Vinyl: ", "Other: "}
set fld to {"First: ", "Last: ", "street: ", "City: ", "State: ", "Zip: ", "phone: ", "Matl: ", "Project Details: ", "contact: ", "referred by: "}
tell application “Mail”
set theMessages to selection
repeat with eachMessage in theMessages
set msg to content of eachMessage
-- Get form of return
repeat with aR in Ret
if msg contains contents of aR then set rtn to contents of aR
end repeat
-- Figure out the Material (Matl)
repeat with aMatl in Mat
if msg contains contents of aMatl then set item 8 of fld to contents of aMatl
end repeat
-- now grab the parts
set tid to AppleScript's text item delimiters
set msgParts to {}
repeat with k from 1 to count fld
set AppleScript's text item delimiters to (fld's item k)
set temp to (last text item of msg)
set AppleScript's text item delimiters to rtn
set end of msgParts to first text item of temp
set AppleScript's text item delimiters to tid
end repeat
if item 8 of msgParts is "on" then set item 8 of msgParts to item 8 of fld & "on"
end repeat
end tell
– now have a list of the parts:
–set the colw to column width of range “B:B”
tell application “Microsoft Excel”
make new document
set horizontal alignment of range “B:B” to horizontal align right
set column width of range “A:A” to 15
set column width of range “B:B” to 20
end tell
repeat with i from 1 to number of items in fld
tell application “Microsoft Excel”
set value of cell ("$A$" & i as string) to item i of fld
set value of cell ("$B$" & i as string) to item i of msgParts
end tell
end repeat