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.

Similar Messages

  • Is anyone else having a problem sending a mail message with PDF attached?

    Is anyone else having a problem sending a mail message with PDF attached? I receive the following message:
    Sending the message content to the server failed.
    Select a different outgoing mail server from the list below or click Try Later to leave the message in your Outbox until it can be sent.
    Is there a fix for this?

    Anyone?  I was hoping my problem would just 'fix itself'...  but I still have some clients telling me they're not receiving any email from me.  I've since deleted that account on my computers and re-added it.  But still having the same issue. 

  • Mail messages disappear - just a blank mail message for all emails

    Mail messages disappear - just a blank mail message for all emails.
    This happens sporadically since I upgraded to Yosemite 10.10.2.
    It happens on all of my machines (Macbook Air, + iMacs) so it must be a software bug.
    Is there an update coming through for Mail?

    Back up all data. Rebuild the mailbox.

  • 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.

  • 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.

  • Export Mail messages as PDF - missing extension

    When exporting messages as PDF files, the resulting files don't seem to become proper PDF files. They show up as some generic file, illegible for Quick View and ignored by many applications as being a PDF. Forcing applications to open them as a PDF reveals that there's nothing wrong inside of it. So all it needs is a correct extension (whether or not it is shown). Adding the ".pdf" extension manually or by some batch conversion utility, immediately renders the PDF correctly.

    I figured it out.
    There was a setting in my pdf that had adobe layers on. I turned it off.
    All good now!

  • Batch save Mail messages as PDF's

    I am in need of saving all of my email messages in my inbox as individual PDF documents. I know you can do it one at a time via "Print>save as PDF" but we are talking about a few hundred email messages here.
    Is there anyway to take advantage of something like automator or could someone show me some software to batch save all of these messages?
    Thanks so much for the help.
    -Christian

    Dansyacht wrote:
    In Mail, select all the messages to print (a smart mailbox may help).  When all are selected do a file > save as (RTF or plain text).  This will create one printable file with all the messages.  You can then load this file into TextEdit and print it as a PDF.
    Thanks -- this may be what I go with.  However, when I tried this the rtf file did contain all of the messages, but did not show the header information on each (To:, From:, Date: ...), so I continued my search for a solution.  I think I found something that works.  My project is actually larger than what I described.  Interested people may be able to use some or all of the following.
    The project started when I asked a friend to send me all of the emails that I have sent him over the last 15 years.  He had archived them all in Windows / Outlook Express.  I had not archived them.  He was able to give me a .DBX file containing them all.  I used a free program called DbxConv in Windows to convert the .DBX file to a .MBX file.
    In Apple Mail I did File/Import_Mailboxes/File_In_mbox_Format to import them.  Then, View/Organize_by_Conversation (checked on).  Select all messages and File/Print/PDF/Save_As_PDF into a new folder on the desktop.  This will generate many pdfs.
    Now the new part:
    Next, drag all of the PDFs into Preview.  Finally, in Preview, File/Print/PDF/Save_As_PDF.  This will create a single pdf file with all messages, including imbedded attachments, with info displayed in your current Apple Mail format -- dependent on how you like your Apple Mail messages displayed (minimal header, expanded header, etc.) . . . . .  I think!
    At least it worked for me, once.  I try it again and see what develops.

  • 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"

  • Restoring mail messages and attachments from Library Mail folder

    Can someone please tell me the best way to do the following...
    I have recently performed an erase and install of Snow Leopard.
    I need to restore my old mail and I have the following data...
    A copy of the "Mail" folder from the "Library" folder, up-to-date as of yesterday (19/9/09). I omitted to take a copy of the "Mail Downloads" folder which I believe contains the attachments for the messages.
    An older copy of the "Mail Downloads" folder, up-to-date as of 31/5/09.
    I was advised by one person at Apple Care that the Mail Folder was all I needed to back-up all my mail. Then the next advisor told me I should have taken a copy of the Mail Downloads folder as well. Another advisor suggested I exported all the mailboxes manually one by one which I now wish I had done.
    In any case, I am where I am and I would like to know what to do with the data I have to be able to access my past mail messages.

    Robert,
    If you were to need to do this again, all you need is to restore the Mail folder and the com.apple.mail.plist file (Home/Library/Preferences). If you restore those -- replacing any that might get created, but would not if you don't first launch Mail -- then Import is not necessary and it picks up where it left off.
    The Mail Downloads folder is not needed -- its contents are redundant to what is kept with the messages.
    Ernie

  • Mail messages won't load in Mail 4.5

    After a seeming successful installation of Snow Leopard, my Mac Mail also seemed to update properly (4.5). All my incoming items are listed. However, after double clicking on any e-mail in the inbox, a window opens up with the title of the e-mail, but then I get a spinning-spoke "Loading." No content opens and the "Mail" won't close without a Force Quit. Same result with a single click and "Open" from the Mail file menu. E-mail messages succesfully sent.

    Some things to check:
    Is the drive still plugged in?
    Is the drive visible in Finder?
    Is the drive visible in Disk Utility?
    Is Time Machine still turned on (System Preferences > Time Machine)?
    Is the Buffalo drive still selected as the Time Machine destination?
    Assuming all those answer are "yes," look for Time Machine errors in the system log. (Search for "backupd" in the system log using the Console app in /Applications/Utilities; you may may need to log on as an administrator to see those entries.)

  • Cannot get mail message, then later I get mail

    Cannot get mail message for all accounts, then later without doing anything I get my mail a couple of hours late. Have screen shot but can't seem to insert it here.

    Hello there dinadinadina,
    It sounds like you have modified the password settings for your Gmail account after changing the password. Thats where I would have started too. Next I would restart the device and test it one more time, and then remove and add the account again in Settings:
    Get help with Mail on iPhone, iPad, and iPod touch
    Restart your iOS device.
    Delete the affected email account from your device.
    Tap Settings > Mail, Contacts, Calendars.
    Tap the affected email account.
    Tap Delete Account.
    Add your account again.
    Thank you for using Apple Support Communities.
    Take care,
    Sterling

Maybe you are looking for