• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Strange Font Pasted in Mail
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Strange Font Pasted in Mail


  • Subject: Strange Font Pasted in Mail
  • From: Christopher Stone <email@hidden>
  • Date: Mon, 6 Jul 2009 04:21:33 -0500

Hey Folks,

I'm trying to rebuild an old script I wrote for Eudora to derive the salutation from the to-address.  Unfortunately there's still no way to set the 'selected text' in Mail, so I'm having to use the clipboard.

The weird thing is that the pasted text is Helvetica 12 even though I have my default message text set to Courier 12, and I can't seem to find a way around this.  Any ideas?

tell application "Mail"
activate

tell application "System Events"
keystroke "s" using {command down}
end tell

delay 0.1

try
set winName to name of front window
set msg to item 1 of (messages of drafts mailbox whose subject is winName)
tell msg
set msgHeaders to all headers
end tell

--  Uses Satimage Osax:
-- set fStr to "^To: ([^ ]+)"
-- set rStr to "\\1"
-- 
-- set foundStr to find text fStr ¬
-- in msgHeaders using rStr ¬
-- regexp true ¬
-- with string result

-- Pure Applescript replacement for Satimage-specific code:
set AppleScript's text item delimiters to "To: "
set hList to text items of msgHeaders
set foundStr to first word of first paragraph of item 2 of hList
set AppleScript's text item delimiters to ""

on error errMsg number errNum
beep
display dialog errMsg & return & return & "Error Number: " & errNum
end try
end tell

set the clipboard to ("Hey " & foundStr & "," & return & return & return) as string

tell application "System Events"
keystroke "v" using {command down}
end tell

If I can get this working satisfactorily I'll add a lookup table to customize the salutation for specific individuals.

I'm pleased to have figured out a way to reference the front outgoing message, but if anyone has a better way I'd sure like to know.

Thanks.


Best Regards,

Chris

P.S.  Just a plug for the Satimage Osax.  Although shell scripting is fast enough these days to not exact much penalty for its usage, I still prefer my old friend for regular expressions and assorted other useful features.  (Not affiliated with Satimage.)
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Strange Font Pasted in Mail
      • From: Christopher Stone <email@hidden>
    • Re: Strange Font Pasted in Mail
      • From: Yvan KOENIG <email@hidden>
  • Prev by Date: Re: Rép: Unicode versus Utf8
  • Next by Date: Re: Strange Font Pasted in Mail
  • Previous by thread: Re: Editing Incoming Messages in Mail
  • Next by thread: Re: Strange Font Pasted in Mail
  • Index(es):
    • Date
    • Thread