I have been running the script below for some time:
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
repeat with i from 1 to (count paragraphs of theContent)
if paragraph i of theContent � "" then
set nameLine to paragraph i of theContent
repeat while nameLine starts with ">"
set nameLine to text 2 thru -1 of nameLine
end repeat
try
repeat while character 1 of nameLine = " "
set nameLine to text 2 thru -1 of nameLine
end repeat
set AppleScript's text item delimiters to {"<"}
try
set dName to text item 1 of nameLine
try
set dName to text 1 thru -2 of dName
on error -- no name, but < > around email addrtess
set dName to ""
end try
set eAddress to text item 2 of nameLine -- may error
if no email address
set AppleScript's text item delimiters to {">"}
set eAddress to text item 1 of eAddress
on error
if nameLine contains "@" and nameLine does not
contain " " then
set dName to ""
set eAddress to nameLine
else
set dName to nameLine
set eAddress to address of sender of theMsg
end if
end try
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 try
end if
end repeat
end if
end tell
The script's function is to take an email originally sent to my lotus notes
account and subsequently forwarded to my pop mail account and put in the
correct sender. In other words we are trying to simulate Lotus Notes
redirecting the mail rather than forwarding it.
The problem arises because our great corporate IT department has changed the
format in which Lotus Notes email is received. I have no power to change the
document design as that is the much cleaner solution. The new Lotus Notes
mail format for a received message is:
> One attachment (363k)
>
> CSR News
> Releases To: News
> <NewsReleases@c Releases 1
> sr.com.au> <NewRelease@csr.
> com.au>
> 10/09/2001 cc:
> 10:09 AM Subject: CSR
> appoints new
> Chief Financial
> Officer
>
>
>
> Please find the attached CSR news release titled 'CSR appoints new Chief
It can be seen that if the messages has an attachment that information is
presented in the first line of the message.
A split column format is then used so that the sender information (name and
email address) may be split over a number of lines.
Another example is shown below:
> barry_kodesh@
> splwg.com To:
> [EMAIL PROTECTED]
> 05/09/2001 cc:
> 03:28 PM rkellerman@perpetual
> .com.au
> Subject: Six - A
> - Side & Year End
> Function
What I'm wondering is if someone (Paul is the only person I am thinking of)
can modify the above script so that the correct sender is set.
Basically I'm thinking the script needs to be modifed as follows:
1 Check if the first line contains the word attachment. If so ignore it.
2 Otherwise the next line will either contain part of the name of the
sender or the first part of the email address
3 If the sender has a name the email address will be contained within
angle brackets and can be formed by taking all the of the characters in a
line after an angle bracket up to a space and all the characters on the next
line (ignoring leading spaces) until a closing angle bracket is
encountered.
4 If the sender has no name but just an email address then the email
address is formed by all the non blank characters on each line until a space
is encountered or until a line's first character is after position 21.
In fact the email address or sender name appears to start at position 21 and
continues until a space is encountered.
Sorry for such a long post.
But I use this script every day all day. If my description is unclear please
let me know.
-- David Leitch JPMorgan [EMAIL PROTECTED] +612 9220 1609
--
To unsubscribe: <mailto:[EMAIL PROTECTED]>
To search the archives:
<http://www.mail-archive.com/entourage-talk%40lists.boingo.com/>