Applescript for Mail Question

Is it possible to create an Applescript for Mail, that, when an email with a specific subject line arrives in my inbox, an attached photograph would get sent immediately in response to the person who sent the email.  The subject lines would vary (e.g., people_1, or, places_16).  Every subject line would have a corresponding photo located somewhere on my hard drive (there would be hundreds of possibilities - the catalogue would be concentrated in one place).  So, for example, when "places_21" hits my Mail in box, an email would be generated in response, automatically, with a photo (places_21) attached.  Thank you!  Marcos

Actually, it's not that hard to do, it's just that there are a lot of use cases, and a lot of caveats to consider.
For example, do you intend/expect to work from a predefined list of image file names? Or do you want/expect to react to any filename that's requested?
You say that the files would be 'somewhere on my hard drive'... how does the script know where to look? How does it resolve filename conflicts? What should happen if a file can't be found?
As fane suggests, you should also consider an audit log, so you can see who asked for what, and when, along with errors that occurred on the way.
So it's entirely do-able, just a lot of questions to answer before you get started.

Similar Messages

  • AppleScript for mail merge

    What is AppleScript for mail merge

    AppleScript is a programming language that is tied to certain Applications that support it. Pages v5.5.1 has a scripting dictionary of the terms it will support via AppleScript. Apple's answer to not including Mail Merge functionality in Pages v5.5.1 is for individual users to roll their own, download an example and adapt it, or use another application with built-in Mail merge features.
    See my previous post to you.

  • Applescript for mail error can't get message id

    I have an applescript (found on internet) for Mail 4.5 that deletes messages in "on my mac" mailbox "Deleted Inbox" that are older than 120 days. The script runs from an iCal daily event. I drag messages from Inbox to "Deleted Inbox" when I don't want the message in Inbox, but I want to save the message for 120 days before deleting it. The script sometimes runs successfully, and sometimes gives error "Mail got an error: Can't get message id xxx of mailbox "Deleted Inbox"". Then in Mail, I "Mailbox / Rebuild" that mailbox, and run the script manually without error. How can I avoid that error? The script is essentially:
    tell application "Mail"
              set OldStuff to every message of mailbox TheBox where date received of it < OldDate
              repeat with ThisMessage in OldStuff
        delete ThisMessage
              end repeat
    end tell
    Thanks for any help.
    Ken

    How can I avoid that error?
    I don't actually know how you can avoid that error. However, maybe you can use a workaround and have the script rebuild the mailboxes automatically when such an error occurs. Try the following code:
    tell application "Mail"
      try
        set OldStuff to every message of mailbox TheBox where date received of it < OldDate
      on error
        activate
        tell application "System Events" to click menu item "Rebuild" of menu 1 of menu bar item "Mailbox" of menu bar 1 of process "Mail"
        delay 1 -- adjust if necessary
        set OldStuff to every message of mailbox TheBox where date received of it < OldDate
      end try
      repeat with ThisMessage in OldStuff
        delete ThisMessage
      end repeat
    end tell
    Since the above script uses GUI Scripting, you must enable the Accessibility Frameworks by clicking the checkbox labeled "Enable access for assistive devices" in the Universal Access System Preference pane.
    Message was edited by: Pierre L.

  • Which community for Mail questions?

    Mail is not listed as a community and wherever I did post a Mail question, I got zero response.
    So which is the right community to post in?
    Thanks,
    Raphael

    Thanks.
    I can't figure out how to get there. Would you lay out the path for me please?
    Thanks,
    Raphael

  • AppleScript for mail merge with Excel data?

    Is there any approach for an AppleScript that lets you use Excel data as source for some kind of mail merge operations? If not, would anyone here be interested if someone (I?) would take a closer look at some kind of a (AppleScript Studio) solution for this?

    I'm not sure I get the question.
    If it is "could you use AppleScript to create mail merge for Pages with Excel?", the answer is, Yes. Both Pages and Excel are scriptable.
    If the question is "has anyone done it yet?", I don't know, but it could be a fun exercise.
    If the question is "would there be a market, if someone (you?) wrote and released such a script?", I cannot tell, but personally I would probably write a hack that worked only for my own needs - if I had them. The overhead with usability, testing, different address formats, languages, different Excel sheet formats, and so on, makes me guess that the investment wouldn't pay off for a generic solution. Especially considering both Pages and MS Office already have their own mail merge functions.

  • Export mail message as PDF Applescript for mail rules

    I have looked everywhere for this and found nothing. I don't have 40 hours to learn applescript myself but from the little I do know this should be possible. Probably easy.
    I want to created an applescript to run as a mail rule. I want the script to export the message as a PDF and move that PDF to a specified folder. Hazel can take it from there.
    for instance:
    Fedex sends me a email message that my shipment has been delivered.
    mail rule kicks in and runs the script
    script creates a PDF of the message
    message is moved to "fedex delivered" folder

    I found a workaround, though there must be something neater.
    I added this before my script
    tell application "System Events"
              tell process "Mail"
                        tell menu bar 1
                                  tell menu bar item "View"
                                            tell menu "View"
                                                      tell menu item "Sort By"
                                                                tell menu "Sort By"
                                                                          click menu item "Subject"
                                                                end tell
                                                      end tell
                                            end tell
                                  end tell
                        end tell
              end tell
    end tell
    then the same except "Date" instead of "Subject".
    My script does what i want now.

  • Writing an AppleScript for Mail

    I have never written an AppleScript before, so I don't know if this is even possible. But, here goes...
    I manually process my junk mail by opening each message, clicking on "Long Headers," and forwarding to [email protected] Is it possible to write a script that would allow this process to be automated?
    Thanks.

    You can get the header text with this Applescript:
    Click here to launch Script Editor.
    tell application "Mail"
    the selection
    properties of item 1 of the result
    set thisHeader to all headers of the result
    end tell
    There is a sample Applescript included with Mail.app called "Create New Message.scpt", it should contain snippets to get you going.
    Or Google and there will be plenty of simpler ones. Truth be told, the Apple sample scripts are about the worst for learning from.

  • Applescript for mail.app won't send attachment

    I have an applescript to send a mail attachment but the mail sends without the attachment? Anyone know why?
    set theContent to (current date) as string
    set theSubject to "excel file"
    set theTarget to "someone @someplace.com"
    set theSender to "admin"
    set theName to "some name"
    set theAttachment to "mcp0_HD:Users:bill:Site:logs:deviceLogs.xls"
    tell application "Mail"
    set newMessage to make new outgoing message with properties {subject:theSubject, content:theContent & return & return}
    tell newMessage
    make new to recipient at end of to recipients with properties {visible:true, name:theName, address:theTarget}
    set sender to theSender
    tell content
    make new attachment with properties {file name:theAttachment} at after the last paragraph
    send newMessage
    end tell
    end tell
    end tell

    If you are still having problems, then there is something wrong with your file that you are trying to attach, or your declaration of this variable:
    set theAttachment to "mcp0_HD:Users:bill:Site:logs:deviceLogs.xls"
    Examine that very carefully. It is also a good idea to use the *path to* nomenclature (see the Dictionary for *+Standard Additions+* for more details) to access a file in cases like these. For example, here is the pertinent portion of a script that I have used since the Panther days to do precisely what you are trying to do:
    set pay_Path to ((path to documents folder as text) & "Cathouse:Payroll:Paysheets:Today.xls")
    tell application "Mail"
    set b to make new outgoing message with properties {sender:"[email protected]", subject:("Payroll")}
    set content of b to "Hello:
    Here is the payroll ending today: " & return & return
    tell b's content
    make new attachment with properties {file name:pay_Path as alias} at after the last paragraph
    end tell
    tell b to make new to recipient with properties {address:"[email protected]"}
    send b
    end tell
    I use this every other week to report my payroll to my accountant. It has never failed, and I am using Leopard (10.5.7).
    Good luck,

  • Applescript for mail rule

    I found this on Mactech. All I did was add the line "make new outgoing........", well, it does NOT work. What do you have to do to make Mail trigger an applescript. All I want to do is when I an email reminder, to just make a new email message with Happy Birthday in the Subject. I'll click the stationary and add a birthday background. Any help would be appreciated.
    using terms from application "Mail"
    on perform mail action with messages theSelectedMessages for rule theRule
    repeat with a from 1 to count theSelectedMessages
    make new outgoing message with properties {visible:true, subject:"Happy Birthday", content:"Happy Birthday "}
    end repeat
    end perform mail action with messages
    end using terms from

    sorry but your suggestion did NOT work. Here is what I wrote and it did NOT make a difference the script will NOT generate an outgoing message.
    using terms from application "Mail"
    on perform mail action with messages newMessages
    repeat with newMessage in newMessages
    tell application "Mail"
    set senderName to (extract name from sender of newMessage)
    say "You've just received an email from " & senderName
    say (subject of newMessage) as string
    if (subject of newMessage) contains "birthday" then
    tell application "Mail"
    activate
    make new outgoing message with properties {visible:true, subject:"Happy Birthday", content:"Happy Birthday "}
    end tell
    end if
    end tell
    end repeat
    What I was able to do was embed a line of code to call another script that does successfully create an out going message. Here is the successful script.
    using terms from application "Mail"
    on perform mail action with messages newMessages
    repeat with newMessage in newMessages
    tell application "Mail"
    set senderName to (extract name from sender of newMessage)
    say "You've just received an email from " & senderName
    say (subject of newMessage) as string
    end tell
    end repeat
    tell application "Finder"
    open "Macintosh HD:Users:Shawn:Documents:Applescripts:Mail scripts:make outgoing email happy birthday5.app"
    end tell
    end perform mail action with messages
    end using terms from
    here is the make birthday5 app
    tell application "Mail"
    activate
    make new outgoing message with properties {visible:true, subject:"Happy Birthday", content:"Happy Birthday "}
    end tell
    Now when I get my birthday reminder, according to the "Rule" set up in preferences, if the subject contains "birthday" the script will read the name and subject and generate an outgoing message with Happy Birthday in the Subject and Body.....all I have to do is add some birthday stationary, type in a sappy line and viola, done. See why I love Macs so much.

  • AppleScript for Mail

    Is it possible to make an applescript that will check for unread messages through the whole mailbox, then tell me how many there are, then say who each unread mail is from. Ask me to have it read the subject then open, mark as read, or leave for later?

    just like to add in my script based on the above
    i've been looking for something similar to this for a while and tried allsorts of snipets from many of the posts so heres my attempt
    this actually uses the mailbox or folder that is selected in mail.app so you dont have to explicitly tell it which folder you want to use (had that part of the code from another post somewhere so credit to them not me
    display alert "Please note!" message "This script may take a while if you have a lot of mailboxes selected. Do you want to continue?" buttons {"Cancel", "Yes"} cancel button "Cancel"
    tell application "Mail"
              tell front message viewer
                        set theSelectedMailboxes to selected mailboxes
                        repeat with a from 1 to length of theSelectedMailboxes
                                  set theCurrentMailbox to item a of theSelectedMailboxes
      processMailbox(theCurrentMailbox) of me
                        end repeat
              end tell
    end tell
    on processMailbox(theMailbox)
              tell application "Mail"
                        set unread_messages to (messages of theMailbox whose read status is false)
                        set unread_count to count unread_messages
      --display dialog "Total unread messages: " & unread_count
                        repeat with each_message in unread_messages
                                  set the_subject to subject of each_message
                                  set the_sender to sender of each_message
                                  set the_action to choose from list {"Open", "Mark as read", "Keep for later", "Delete"} default items {} with prompt "Subject: " & the_subject & return & return & "Sender: " & the_sender & return & return & "What do you want to do with this message?" & return with title "Unread message" without multiple selections allowed
                                  if the_action is false then return
                                  if item 1 of the_action is "Open" then open each_message
                                  if item 1 of the_action is "Mark as read" then set read status of each_message to true
                                  if item 1 of the_action is "Delete" then
                                            set read status of each_message to true
                                            set junk mail status of each_message to true
                                  end if
                        end repeat
              end tell
              tell application "AppleScript Editor"
      activate
                        display dialog "Do you want to delete the email?" buttons {"yes", "no"} default button 2
                        if result = {button returned:"yes"} then
                                  tell application "Mail"
      # deletes every message that is Read and marked as Junk.
      # Any that are not read AND junk will remain.
                                            delete (every message of theMailbox whose junk mail status is true and read status is true)
                                  end tell
                        else
                                  if result = {button returned:"no"} then
                                  end if
                        end if
              end tell
    end processMailbox

  • Applescript for mail to speak 'sent to'

    Hey, I use 6 mail accounts in mac mail, 4 of which are work addresses. I get a lot of mail to my 2 personal addresses which is low priority but i would like to setup speech to say the 'sent to' address when mail arrives. my computer screen is on sleep a lot of the time so if a mail arrives to a high-priority work address I would wake my screen to read immediately. Does anyone know of a script that would speak the mailbox/sent to name? thanks guys, dren.

    --- Code starts here ---
    using terms from application "Mail"
    on perform mail action with messages tMessages
    tell application "Mail"
    repeat with tMessage in tMessages
    say "Sent to " & (name of account of mailbox of tMessage)
    end repeat
    end tell
    end perform mail action with messages
    end using terms from
    --- Code ends here ---
    In 'Mail' 'Preferences' -
    01. Create a new rule.
    02. Leave the first popup button set to 'any', and select 'Every Message' from second popup button.
    03. Under 'Perform the following actions:', select 'Run AppleScript' from the only popup button.
    04. Click on the respective popup button's 'Choose...' button and navigate to where the above code is saved (as an AppleScript script file).

  • Applescript for Mail Simple Problem

    I am a professor, and I am looking to write several simple scripts for Apple's Mail client.  These scripts all involve replying to students (vs. replying to colleagues, or others).
    The first script I am looking for would create a new blank message and set the signature of that message to a predefined sig called "Teaching".
    What I have so far is:
    tell application "Mail"
        activate
        set theMsg to make new outgoing message with properties {visible:true}
        set message signature of theMsg to "Teaching"
    end tell
    This script hangs at "activate", resulting in a timeout error (why???).  If I delete the activate command, the new message is created, and then Mail times out.
    Any suggestions appreciated.
    Warmly,
    Professor E

    Hi,
    You must specify the signature like this :
    set message signature of theMsg to signature "Teaching"

  • Applescript for Mail 2.x

    Hi,
    Does anyone have a script that will save the attachments (from a folder called Requisition in Mail) in a folder located on the desktop? Have been trying but to no avail!
    Thanks and appreciate any help in this matter.

    set source_Folder to "Requisition" -- Name of source folder.
    set destination_Folder to "From Requisition" -- Name of destination folder.
    try -- Optional code, to ensure existance of 'destination_Folder'
    tell application "Finder" to make new folder at (path to desktop folder from user domain) with properties {name:destination_Folder}
    end try
    -- Code to move contents from 'source_Folder' to 'destination_Folder'.
    tell application "Finder" to move items of folder (((path to library folder from user domain) as string) & "Mail:" & source_Folder) to folder (((path to desktop folder from user domain) as string) & destination_Folder)
    ... or, hard-coded as, ...
    try -- Optional code, to ensure existance of 'destination_Folder'
    tell application "Finder" to make new folder at (path to desktop folder from user domain) with properties {name:"From Requisition"}
    end try
    -- Code to move contents from 'source_Folder' to 'destination_Folder'.
    tell application "Finder" to move items of folder (((path to library folder from user domain) as string) & "Mail:Requisition") to folder (((path to desktop folder from user domain) as string) & "From Requisition")
    ... Or, if a sub-set of files of 'Requisition' is desired, ...
    set source_Folder to "Requisition" -- Name of source folder.
    set destination_Folder to "From Requisition" -- Name of destination folder.
    set sourceFolderPath to (((path to library folder from user domain) as string) & "Mail:" & source_Folder & ":")
    try -- Optional code, to ensure existance of 'destination_Folder'
    tell application "Finder" to make new folder at (path to desktop folder from user domain) with properties {name:destination_Folder}
    end try
    try
    set tList to list folder sourceFolderPath without invisibles -- Obtain list of 'source_Folder's contents.
    -- Present 'tList' in 'choose from list' window, and accept single or multiples selections, or the 'Cancel' action.
    set selected_Files to choose from list tList with prompt "select File(s):" with multiple selections allowed without empty selection allowed
    repeat with i in selected_Files -- Cycle through the selected files.
    -- Move selected files from 'source_Folder' to 'destination_Folder'.
    tell application "Finder" to move file ((sourceFolderPath & i) as alias) to folder (((path to desktop folder from user domain) as string) & destination_Folder)
    end repeat
    end try
      Mac OS X (10.4.4)  

  • Using AppleScript in Mail Rules

    I can't figure out how to edit an AppleScript for Mail to perform the following:
    1) After moving a filtered incoming message to a prescribed folder (can do this easily), open the message in a new window (or go to the folder and show message).
    2) Before sending a message, specify a folder to store the outgoing message. This could be done via bcc in Eudora, and can be done separately in Entourage, but I don't know enough to figure out how to do it in Mail.
    Thanks for any suggestions.

    gauthier,
    1) After moving a filtered incoming message to a prescribed folder (can do this easily), open the message in a new window (or go to the folder and show message).
    You might want to take a look at the Open Message and Open Mailbox scripts available from Mail Scripts - they should do exactly what you are looking for:
    http://homepage.mac.com/aamann/
    2) Before sending a message, specify a folder to store the outgoing message. [...]
    This is not possible in Mail since you cannot hook into the sending action to perform actions before sending (and rules per se don't apply to outgoing messages). However, you might check out the Filter Sent Messages script from the above referenced Mail Scripts as somewhat of a work-around.
    Andreas

  • Simple question; Mac Server Setup for Mail, iCal and Address Book Services.

    Hi Guys;
    I'm new to the Mac Server world and need a few questions answered.
    I have purchased a new Mac mini Server for hosting File, Web, Mail, iCal and Address Book Services.
    I’m comfortable setting up File and Web Services however I’m a bit uneasy setting up Mail, iCal and Address Book services to be access locally and remotely(via the internet).
    My current setup is;
    Internet connection (Dynamic IP) -> Router -> Mac mini Server.
    I have purchased a domain name (Thornton-net.com) from DynDns.com + a custom DNS service as I can setup my router to update my domain’s IP address automatically.
    I can access File and Web Services remotely (thortnon-net.com) perfectly without any issues via the Port Forwarding feature of the Router.
    If I setup Mail, iCal and Address Book Services -> will Mail, iCal and Address Book clients be able to access these services hosted by the server via Thornton-net.com?
    Message was edited by: Allan.Thornton

    Welcome to the forums.
    For mail services (and specifically for your outbound mail to be accepted by other mail servers) your mail server needs to have a static IP address and matching forward and reverse and MX records, or a tunnel to a static IP (with matching DNS), or you need another mail server where you have an authorized relay. Without that, your mail will be considered a spam engine, and dropped.
    Additionally, your particular tier of service with your ISP (with a static IP) will generally allow server-oriented access and server-oriented network traffic, where a residential or other tier of service (with a dynamic IP addresses) can be firewalled.
    The ISP controls the "high ground" of the network connections here, so you pretty much get to play by their rules and requirements. If they don't offer static IP, then (presuming their T&Cs permit it) you get to tunnel (via IPv6, for instance) to a tunnel broker, and receive your network traffic via that (and with matching DNS) point of presence. That could well be a tunnel for your mail at whichever your DNS provider is here, because you'll have issues with your dynamic address. (You get to sort out if they offer that.)
    Far and away the easiest approach (if you want to host this stuff yourself) is to work with the ISP. They're inherently involved in your network, and they and they alone have full control over your reverse DNS configuration.

Maybe you are looking for

  • Purchase and Activation

    I bought the developer license and Apple have debited my credit card in the amount of $ 99.00. And until now Apple has not sent the confirmation email. Has anyone experienced this? Thanks Junior Santos

  • Amount is different in VBRK and VBRP

    For currency USD, why the amount posted to NETWR in VBRK is correct and amount posted to NETWR in VBRP is with 2 decimal places. Example, total of 226.472,0000 USD but posted as 22.647.200,00.

  • Oracle Files Install

    Is there a down-load site where I could get just the Oracle Files component without downloading the entire Collaboration Suite? If so, please provide the URL. I wish to use Oracle Files for content management. We have the ContentMangagement SDK alrea

  • Adobe Air Developer - Central London - £250-300/day

    Adobe Air Developer needed ASAP. The project is to build a very simple download manager for music files being purchased on an ecommerce Web site that they are building. They are designing the application but need a developer to pull it together. Our

  • Crashes at start up

    Just purchased Dreamweaver cs4, but it crashes at start up. The loader appears, but nothing more... http://i39.tinypic.com/21dgzdi.jpg <- Program stops responding. Anyone have any clue what I can do to fix it? I've tried reinstalling it, and I haven'