Title: Re: Custom script help needed to modify
On or near 9/10/01 12:00 AM, David Leitch at [EMAIL PROTECTED] observed:
> But I use this script every day all day. If my description is unclear please
> let me know.
The following works on the two examples you provided; I just copied them into two text files, test1.txt and test2.txt, and ran the script against those files in Finder, rather than as a script in Entourage. I have then spliced that code into your original script, replacing its guts but keeping the shell of it. Should work; let me know. It’s possible that certain cases will fail if they don’t follow the pattern of the two examples very closely...
tell application "Microsoft EntourageSR1"
set theMsg to item 1 of (get current messages)
if address of sender of theMsg is "[EMAIL PROTECTED]" then
set theContent to content of theMsg
-- Remove leading blanks
-- Collapse space runs to single space
set paras to paragraphs of theContent
set newstuff to ""
repeat with aLine in paras
repeat while aLine begins with " "
if aLine is not " " then
set aLine to text 2 thru -1 of aLine
else
set aLine to ""
end if
end repeat
repeat while aLine contains " "
set aLine to myReplace(" ", " ", aLine)
end repeat
if length of aLine > 0 then set newstuff to newstuff & aLine & return
end repeat
if ((words 1 thru 3 of newstuff) as text) contains "attachment" then
set newstuff to myAfter(")", newstuff) -- Discard the attachment info
end if
set trialAddress to word 1 of newstuff
if trialAddress contains "@" then
set finalAddress to trialAddress -- We are done
return finalAddress
else
set trialAddress to myBefore("To:", newstuff)
set trialAddress to myReplace(return, "", trialAddress)
if trialAddress does not contain "@" then
set part2 to myBetween("<", ">", newstuff)
set part2 to "<" & myBefore(" ", part2) & myAfter(return, part2) & ">"
set trialAddress to trialAddress & " " & part2
end if
set finalAddress to trialAddress
end if
set nameline to finalAddress
if nameline does not contain "@" then
display dialog "Could not parse sender's address"
return
else
if nameline does not contain " " then
set dName to ""
set eAddress to nameline
else
set dName to myBefore("<", nameline)
set eAddress to myBetween("<", ">", nameline)
end if
set AppleScript's text item delimiters to {""}
set display name of sender of theMsg to dName
set address of sender of theMsg to eAddress
--exit repeat
end if
end if
end tell
on myReplace(oldS, newS, theText)
set od to AppleScript's text item delimiters
set AppleScript's text item delimiters to oldS
set temp to text items of theText
set AppleScript's text item delimiters to newS
set theText to temp as text
return theText
end myReplace
to myBetween(firstPart, secondPart, someString)
set lastpart to myAfter(firstPart, someString) -- What follows firstPart
set midpart to myBefore(secondPart, lastpart)
return midpart
end myBetween
to myBefore(subStr, mainStr)
set od to AppleScript's text item delimiters
set AppleScript's text item delimiters to subStr
set temp to text items of mainStr
set theBefore to item 1 of temp
set theRest to (the rest of temp) as text
set AppleScript's text item delimiters to od
return theBefore
end myBefore
to myAfter(subStr, mainStr)
set od to AppleScript's text item delimiters
set AppleScript's text item delimiters to subStr
set temp to text items of mainStr
set theRest to item 1 of temp
set theAfter to (the rest of temp) as text
set AppleScript's text item delimiters to od
return theAfter
end myAfter
--
Add me to Palm/Visor: http://signature.coola.com/?[EMAIL PROTECTED]
Allen Watson <[EMAIL PROTECTED]> XNS name: =Allen Watson
A Mac family since 1984 <http://home.earthlink.net/~allenwatson/>
Applescripts for Outlook Express and Entourage: <http://homepage.mac.com/allenwatson/>
- Custom script help needed to modify David Leitch
- Allen Watson
