• 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
Mail and attachments
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Mail and attachments


  • Subject: Mail and attachments
  • From: Wayne Melrose <email@hidden>
  • Date: Tue, 19 Jul 2005 09:36:42 +0200

Hi, 

I have modified some text from the applescript archives archives to attach a file to an email. This works fine if the file path is hard coded into the script, although won't work if the filepath is a variable. 

the two working and non-working examples are below.

Any help would be greatly appreciated.





NOT WORKING


set theSubject to "The subject text"
set theBody to "The text of the message"
set theDestinationEmail to "email@hidden"
set myfile to "wayne:Users:waynemelrose:Documents:file.txt"
tell application "Mail"
    set the new_message to (make new outgoing message with properties {visible:true, subject:theSubject, sender:"email@hidden", body:theBody & return})
    tell the new_message
        make new to recipient at end of to recipients with properties {address:theDestinationEmail}
        tell content
            make new attachment with properties {file name:alias myfile} at after the last character
        end tell
    end tell
end tell


WORKING

set theSubject to "The subject text"
set theBody to "The text of the message"
set theDestinationEmail to "email@hidden"
tell application "Mail"
    set the new_message to (make new outgoing message with properties {visible:true, subject:theSubject, sender:"email@hidden", body:theBody & return})
    tell the new_message
        make new to recipient at end of to recipients with properties {address:theDestinationEmail}
        tell content
            make new attachment with properties {file name:alias "wayne:Users:waynemelrose:Documents:file.txt"} at after the last character
        end tell
    end tell
end tell


-------------------------------------
Wayne Melrose 
email@hidden

 _______________________________________________
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: Mail and attachments
      • From: Wayne Melrose <email@hidden>
  • Prev by Date: Reply in Mail 2.0.2 not working?
  • Next by Date: Re: Reply in Mail 2.0.2 not working?
  • Previous by thread: Re: Reply in Mail 2.0.2 not working?
  • Next by thread: Re: Mail and attachments
  • Index(es):
    • Date
    • Thread