I have a house guest arrived Saturday and staying thru Wednesday, so I won't
have time to work on this. You're welcome to try variations yourself, you
know! :-)

I'll get back to you Wednesday if I haven't heard that you fixed it
yourself.

On or near 9/23/01 7:11 PM, David Leitch at [EMAIL PROTECTED]
observed:

> on 24/9/01 9:46 AM, David Leitch at [EMAIL PROTECTED] wrote:
> 
>> on 22/9/01 3:34 AM, Allen Watson at [EMAIL PROTECTED] wrote:
>> 
>>> I modified the script so that if no �@� is found in the address, it will
>>> attempt to make a �JPMorgan.com� address out of it, display a message
>>> showing
>>> what the address is, and ask you want to accept it as is, edit it, or
>>> cancel.
>>> The format, given your example, should be:
>>> 
>>> �Peter C Talbot <[EMAIL PROTECTED]>�
>> 
>> 
>> Allen
>> 
>> Progress is fantasic, however the script is creating addresses of the form
>> 
>> Thomas K Wilson  <> <Thomas.K.Wilson..<>@JPMorgan.com>
>> 
>> I am guessing the extra angle brackets are being added in these lines:
>> if trialAddress does not contain "@" then
>>               set part2 to my myBetween("<", ">", newstuff)
>>               set part2 to "<" & my myBefore(" ", part2) & my
>> myAfter(return, part2) & ">"
>>               set trialAddress to trialAddress & " " & part2
> 
> I'm also noticing that when I edit the address manually in response to the
> presented dialog box
>   set nameLine to text returned of (display dialog "Edit as desired"
> default answer nameLine)
> 
> Then the change is not accepted and indeed no processing is done on the
> addressing. I guessing that in the code fragment below the lines after the
> second else statement
>   set dName to my myBefore("<", nameLine)
>   set eAddress to my myBetween("<", ">", nameLine)
> 
> May actually need to be outside of the else clause. Ie shouldn�t we set
> dname and eddress to the result of of the if else process?
> 
> else if btn = "Edit" then
>               set nameLine to text returned of (display dialog "Edit as
> desired" default answer nameLine)
>               
>           else
>               if nameLine does not contain " " then
>                   set dName to ""
>                   set eAddress to nameLine
>               else
>                   set dName to my myBefore("<", nameLine)
>                   set eAddress to my 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
> 
> Again I repeat the whole script and continue to say thanks. Entourage is far
> preferable to Lotus Notes in terms of user friendliness.
> 
> tell application "Microsoft Entourage"
>   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 my 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 my 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 my myBefore("To:", newstuff)
>           set trialAddress to my myReplace(return, "", trialAddress)
>           if trialAddress does not contain "@" then
>               set part2 to my myBetween("<", ">", newstuff)
>               set part2 to "<" & my myBefore(" ", part2) & my
> 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
>           set nameLine to nameLine & " <" & (my myReplace(" ", ".",
> nameLine) & "@JPMorgan.com") & ">"
>           display dialog "Unclear address, trying: " & nameLine buttons
> {"Cancel", "Edit", "Accept"} default button "Accept" giving up after 15
>           set btn to button returned of result
>           if btn = "Cancel" then
>               return
>           else if btn = "Edit" then
>               set nameLine to text returned of (display dialog "Edit as
> desired" default answer nameLine)
>               
>           else
>               if nameLine does not contain " " then
>                   set dName to ""
>                   set eAddress to nameLine
>               else
>                   set dName to my myBefore("<", nameLine)
>                   set eAddress to my 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 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/>


--
To unsubscribe:               <mailto:[EMAIL PROTECTED]>
To search the archives:
          <http://www.mail-archive.com/entourage-talk%40lists.boingo.com/>

Reply via email to