Sometimes I get mail from a person who uses an email address which isn’t his/her name, or has an unprouncable last name, I’d like Eudora to not read what’s before the @ sign but to recognize that if the address matches cdmclein@cox.net it should say “mail from Cindy” not “mail from c-d-m-c-l-e-i-n.”
I can’t figure out what code to add (or where) to the script below to achieve this.
If you have a solution I’ll appreciate it. I don’t mind adding in the fewer than one dozen specific names that cause this situation to arise. Most of my e-contacts have emailaddresses or handles that are fine, but when the name gets spelled letter by letter it bother me. Thanks.
on perform_mail_action(info)
tell application “Mail”
set theMessages to |SelectedMessages| of info
repeat with thisMessage in theMessages
set AppleScript’s text item delimiters to {“”}
set thisSender to sender of thisMessage as string
set quotepos to offset of “"” in thisSender
if (quotepos is not 0) then
set thisSender to (text items (quotepos + 1) through -1) ¬
of thisSender as string
set quotepos to offset of “"” in thisSender
if (quotepos is not 0) then
set thisSender to (text items 1 through (quotepos - 1)) ¬
of thisSender as string
end if
else
set atpos to offset of “@” in thisSender
if (atpos is not 0) then
set thisSender to (text items 1 through (atpos - 1)) ¬
of thisSender as string
end if
set brkpos to offset of “<” in thisSender
if (brkpos is not 0) then
set thisSender to (text items (brkpos + 1) through -1) ¬
of thisSender as string
end if
end if
tell application “Finder” to say "Mail from " & thisSender
end repeat
end tell
end perform_mail_action
Just before you “tell application “Finder” to say…” you could insert something like this:
set thisSender to "bgl24" -- not including this line, of course; this is just a test.
set oddFriends to {"cdmclein", "bgl24", "23skidoo"} -- can be anywhere
set elseNames to {"Cindy", "Brian", "Susan"} -- with this following oddFriends in the same order, of course
-- this part just before the "say" line
if thisSender is in oddFriends then
repeat with k from 1 to count of oddFriends
if thisSender = item k of oddFriends then
set thisSender to item k of elseNames
exit repeat
end if
end repeat
end if
thisSender -- again just for testing purposes, you would have:
-- tell application "Finder" to say "Mail from " & thisSender
If I may, perhaps I could just add a small note about the placing of the initial statements. To avoid recreating the lists on every iteration of the repeat loop, it might be slightly more efficient to do the job once - at the beginning of the handler (before the repeat loop kicks in):
[code]on perform_mail_action(info)
set oddFriends to {“cdmclein”, “bgl24”, “23skidoo”} – etc.
set elseNames to {“Cindy”, “Brian”, “Susan”} – etc.
tell application “Mail”