• 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: scripting Apple Mail.app
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: scripting Apple Mail.app


  • Subject: Re: scripting Apple Mail.app
  • From: Neil Faiman <email@hidden>
  • Date: Sun, 2 Oct 2005 19:41:51 -0400


On Oct 2, 2005, at 12:20 PM, email@hidden wrote:

Using Mail 1.3 , I don't see a property or command for this in the dictionary. That is surprising.

On Oct 2, 2005, at 5:07 AM, Bob Cuilla wrote:


I would like to tell "mail" to attach a desktop folder named "folder".. I cant seem to figure this out. Can anyone help?

Remember that in an application with well-designed AppleScript support, most of the interesting stuff will be in the "classes" (nouns) part of the dictionary rather the "commands" (verbs). In the case of Mail, if you look in the (standard) text suite, you will find the "attachment" class.


Where to go from there is, admittedly, less than obvious. The following code is from a handler that is called with a list of files and a subject string, and creates a mail message to a known recipient, with all the specified files attached. There may be better ways to do a lot of this -- I wrote it back in OS X 10.0 or 10.1 days, and haven't touched it since.

set theAttachments to {}
repeat with eachFile in theFiles
copy (alias (eachFile as Unicode text)) to the end of theAttachments
end repeat
tell application "Mail"
make new outgoing message with properties ¬
{subject:theSubject, content:"", sender:"Neil Faiman <email@hiddenn>"}
tell the result
make new recipient at the end of the to recipients with properties ¬
{name:"John Doe", address:my getEmail("John Doe")}
repeat with eachAttachment in theAttachments
make new attachment with properties ¬
{file name:eachAttachment} at after the last paragraph of the content
end repeat
set visible to true
end tell
end tell


on getEmail(theName)
tell application "Address Book" to set theAddress to the value of the first email of person theName as Unicode text
return theAddress
end getEmail



Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: scripting Apple Mail.app
      • From: email@hidden
References: 
 >scripting Apple Mail.app (From: Bob Cuilla <email@hidden>)
 >Re: scripting Apple Mail.app (From: email@hidden)

  • Prev by Date: Re: Getting at some Hidden Clipboard Contents
  • Next by Date: Re: Get current working directory
  • Previous by thread: Re: scripting Apple Mail.app
  • Next by thread: Re: scripting Apple Mail.app
  • Index(es):
    • Date
    • Thread