• 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
Re: Apple Mail ToName Issue
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Apple Mail ToName Issue


  • Subject: Re: Apple Mail ToName Issue
  • From: Christian Boyce <email@hidden>
  • Date: Sat, 23 Oct 2010 19:36:12 -0700

Just to add possible clarification:

When you work with Mail it goes like this:

tell application "Mail"
set my_new_message to make new outgoing message with properties {subject:"Hi there", content:"How are you I am fine", sender:"email@hidden"}
-- Of course you can substitute variables in there
-- now you tell the new message about the recipients
tell my_new_message
set visible to true
make new to recipient at end of to recipients with properties {address:"email@hidden"}
make new cc recipient at end of cc recipients with properties {address:"email@hidden"}
make new bcc recipient at end of bcc recipients with properties {address:"email@hidden"}
end tell
end tell

To Recipients and CC Recipients and BCC Recipients are LISTS. That's the important thing. You can run the script in Script Editor and see what it makes. 

Also--

Try this: click on a message in the Mail message viewer (just click on one in the list). Then run this in Script Editor:

tell application "Mail"
set the_selected_messages to the selection -- a list
set the_message to item 1 of the_selected_messages -- now you have one message
set x to address of to recipients of the_message-- a list of email addresses
return x
end tell

You will get a LIST of email addresses. The thing is, we usually are addressing emails to a single person, but it's still a list. You have to work your way through the items in the list. Something like this:

tell application "Mail"
set the_selected_messages to the selection -- a list
set the_message to item 1 of the_selected_messages -- now you have one message
set x to to recipients of the_message
repeat with an_item in x
set the_address to address of an_item as string
display dialog the_address
end repeat
end tell

Does that help?

c
On Oct 23, 2010, at 6:50 PM, email@hidden wrote:

On Oct 23, 2010, at 12:04 PM, Michelle Steiner wrote:

Now that I've had the time, the reason is very obvious, and shows why my solution will not always work. There may be more than one "to:" addressees in a message.  Therefore, name of to recipient of eachMessage returns a list of the name of every "To:" addressee.  If there is only one "To:" addressee, the result is a list containing only one item.

If there are more than one "To:" addressees, my solution will fail.

You will need to decide how to handle the case with multiple "To:" addressees in your script.  If you're sure that the messages you will be handling have only one, there's no need to change anything, but you still might want to test for multiples just in case.

-- Michelle


Ok - that makes good sense - thanks again for explaining this so clearly.

--
Thanks,
Dave - DealTek
email@hidden
[db-10]

--
Christian Boyce
Christian Boyce and Associates, Mac, iPhone, and iPad Consultants
310-452-3720

Read the Boyce Blog: http://christianboyce.blogspot.com
Follow us on Twitter! http://twitter.com/christianboyce
Be a fan on Facebook! http://tinyurl.com/cboyce-and-associates-facebook

 _______________________________________________
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

  • Prev by Date: Re: Apple Mail ToName Issue
  • Next by Date: AppleScript applications as CGI applications-- does it still work?
  • Previous by thread: Re: Apple Mail ToName Issue
  • Next by thread: Still, script won't run on an older iMac.
  • Index(es):
    • Date
    • Thread