Documentation on applescript for printing in mail

Is there any simple way to tell mail to print a message using applescript
Something like this (setup to run with a rule):
using terms from application "Mail"
          on perform mail action with messages theSelectedMessages for rule theRule
                         repeat with theMessage from 1 to count theSelectedMessages
                 -- Process the current message
                 display dialog "test" buttons {"OK"} default button 1
                 print theMessage without dialog
                         end repeat
          end perform mail action with messages
end using terms from
The script has no isses trigering from rules set in mail but I can't for the life of me figure out the right context to get the "print" command to work or even find any documentation on it for mail.
I have tried tons of diffrent varents of what to put after the "print" command but have yet to get it to do anything.
I know that you can save all the contense of an email into a text file then use textedit to print and I have had no issue getting that working but a lot of the emaills I need printed now are formated with graphics with html so all you get is a garbage text file to print.
Also messed with like:
keypress "p" using command down
To try and manuly get it to print from mail but still no luck.
I have tried to get this working on 10.6, 10.7, and 10.8
Ideally I want this to work on 10.7 not sure how much mail has changed between versions when it comes to applescript.
Anyone have any insite for doing this or am I just crazy thinking this should be a simple applescript?

Yes getting the script to auto save out as a PDF would also be an option but as with the print command I have yet to find a way to get it to save out as a full PDF ony ways to save out the text and then have it made into a PDF.
http://macscripter.net/viewtopic.php?id=25865
This is the script I have gotten working but it only really extracts text.
I know it can print attachments properly but I'm looking to print the body of an email that is formated in html.
Notes
Please note, that pergamail currently doesn't support fancy HTML eMail very good. You won't see any pictures or formatted text in the printouts from pergamail. Maybe this can be overcome in the future by parsing the raw source of the eMail messages with a Python/Ruby/Perl script, then extracting and saving the HTML part, and finally printing it with the «lpr»-command. Maybe.
Future
Currently pergamail creates text files from incoming eMail messages, but it would be much better to directly create HTML or PDF documents to get more control over the print layout. previmail alreday uses an advanced HTML template and Colendarshows hot to create a PDF on the fly, so I might just need to invest another weekend to write an improved version of pergamail
As far as im aware it was never really updated to handle html formating properly.
I also played around with previmail script and it does extract the text better out of an html formated email but it still only gets the text.
I am looking for a more 1:1 way of printing an email.

Similar Messages

  • AppleScript for import from Mail

    Is there an AppleScript that will move mail photo attachments to iPhoto? I will be receiving a lot of emails with photos in the next few weeks. I can use the slideshow in mail to move to iPhoto but would like something faster.

    Curt
    When you receive an email with photos, you will see two buttons just below the email headers. One is Slideshow, the other is Save. Click and hold on the save button and you'll get the 'Add to iPhoto' option.
    Regards
    TD

  • Applescript for printing pdf to printer

    Anyone that can help me with this:
    I need to print a pdf file to a printer from filemaker (applescript i guess)
    The filemaker records holds all information needed:
    The filename and the path to the pdf file
    The number of copies needed
    The printer to send it to (different because of duplex simplex)
    Anyone who have a script i can implement ?

    Assuming you can get the data out of Filemaker (I don't use Filemaker so my example might not be right), it's pretty easy to print PDF files. This should get you started:
    tell application "FileMaker Pro"
    tell current record
    -- the syntax here might not be right!
    set theJob to contents of cell "Job"
    set thePrinter to contents of cell "printer"
    end tell
    end tell
    tell application "Printer Setup Utility"
    set current printer to thePrinter
    open alias theJob
    end tell
    The first part of the script extracts the data from Filemaker (check this, please), then calls Printer Setup Utility to change the current printer to the printer named in thePrinter (which should be the printer name as defined in Printer Setup, and it opens the PDF file (assuming that 'theJob' is a full path to the file itself.
    For the number of copies element it's probably easiest to just wrap the 'open' command in a repeat n times block. There is also a print command in Printer Setup which takes an optional with properties but couldn't get it to work in my quick test here.

  • Applescript to select sheet 1 for printing

    I am writing a script to save as PDF and mail a numbers sheet document: I've got the PDF and mail parts at the ready. What I am lacking is a GUI script that insures I have the correct sheet selected for print.
    How might I select sheet 1 in the sheets scroll area (with Applescript)?
    thanks

    I think this will do what you want to select sheet 1:
    tell sheet sheetName   
      [code to save PDF, mail]
    end tell
    where sheetName is a string (i.e. enclosed in quotes) or is the number 1.
    This, of course, has to be within tell application and tell document 1.

  • How do I ativate word wrap or line wrap for viewing or printing e-mails?

    When I attempt to print e-mails that have lines of words that extend across the page, foxfire cuts off that lines that are over
    a certain number of characters.
    In Explorer this dose not happen, they wrap the over long line to the next line below. They do not cut off lines that are to long.
    How can I fix that, FoxFire did this in the last version but not this version.

    File > Print Preview = using '''100%''' for '''Scale''' and enabling '''Shrink to Fit''' should work, unless you have a broken setting for the left or right margins. If that is the case, you need to reset the hidden prefs involved with printing. <br />
    http://kb.mozillazine.org/Problems_printing_web_pages#Reset_printer

  • Using addresses, can you print duplicate mailing labels for the same address

    using my address book, can I print duplicate mailing labels for the same name and address. 

    I checked the Address Book Print Dialog and I did not see the option to duplicate a single label.
    The only thing you could try is to select the name in your list. Then do Command-P to print which should get you to this dialog box:
    Try changing the # of copies and see if that does what you want. Otherwise I'm not sure and your answer may best be found in the Address Book forum on here.
    You may not want to incue the expense but Microsoft Word will do what you want.

  • Applescript for Mac Mail Email Addresses

    Hey guys,
    Bit of help with scripting here would be awesome:
    I have been trying to collate all the email addresses located in my Mac Mail accounts. To do this I have used the following in Applescript:
    tell application "Mail"
    set selectionMessage to selection -- just select the first message in the folder
    set thisMessage to item 1 of selectionMessage
    set theseMessages to (every message in (mailbox of thisMessage))
    repeat with eachMessage in theseMessages
    set theFrom to (extract address from sender of eachMessage)
    do shell script "echo " & quoted form of theFrom & return & " >> ~/documents/extracted.txt"
    end repeat
    end tell
    This has worked really well, but I would also like the addresses of people I have sent mails to (sent mail account) and also any addresses that are CC'd in emails.
    I have played around with the script, but my little knowledge of the program meant I got only errors! Any help on obtaining these final email addresses would be much appreciated.
    Best regards,
    Simon

    While the script works, two problems are that there are many duplicate email addresses and the list is not sorted.
    The following addresses these problems (and avoids repeated do shell script calls):
    <pre style="
    font-family: Monaco, 'Courier New', Courier, monospace;
    font-size: 10px;
    font-weight: normal;
    margin: 0px;
    padding: 5px;
    border: 1px solid #000000;
    width: 720px; height: 340px;
    color: #000000;
    background-color: #E6E6EE;
    overflow: auto;"
    title="this text can be pasted into the AppleScript Editor">
    tell application "Mail"
    set selectionMessage to selection -- just select the first message in the folder
    set thisMessage to item 1 of selectionMessage
    set theseMessages to (every message in (mailbox of thisMessage))
    set listOfEmails to {}
    repeat with eachMessage in theseMessages
    try
    set theFrom to (extract address from sender of eachMessage)
    if listOfEmails does not contain theFrom then
    copy theFrom to the end of listOfEmails
    end if
    if (address of to recipient) of eachMessage is not {} then
    repeat with i from 1 to count of to recipient of eachMessage
    set theTo to (address of to recipient i) of eachMessage as string
    if listOfEmails does not contain theTo then
    copy theTo to the end of listOfEmails
    end if
    end repeat
    end if
    if (address of cc recipient) of eachMessage is not {} then
    repeat with i from 1 to count of cc recipient of eachMessage
    set theCC to (address of cc recipient i) of eachMessage as string
    if listOfEmails does not contain theCC then
    copy theCC to the end of listOfEmails
    end if
    end repeat
    end if
    end try
    end repeat
    end tell
    tell application "Finder" to set ptd to path to documents folder as string
    set theFile to ptd & "extracted.txt"
    set theFileID to open for access theFile with write permission
    set SortedListOfEmails to simple_sort(listOfEmails)
    repeat with i from 1 to count of SortedListOfEmails
    write item i of SortedListOfEmails & return to theFileID as «class utf8»
    end repeat
    close access theFileID
    on simple_sort(my_list)
    set the index_list to {}
    set the sorted_list to {}
    repeat (the number of items in my_list) times
    set the low_item to ""
    repeat with i from 1 to (number of items in my_list)
    if i is not in the index_list then
    set this_item to item i of my_list as text
    if the low_item is "" then
    set the low_item to this_item
    set the low_item_index to i
    else if this_item comes before the low_item then
    set the low_item to this_item
    set the low_item_index to i
    end if
    end if
    end repeat
    set the end of sorted_list to the low_item
    set the end of the index_list to the low_item_index
    end repeat
    return the sorted_list
    end simple_sort</pre>

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

  • Single keyboard shortcut needed for doing the Mail PDF

    I very frequently e-mail Word files (using Apple Mail) as PDFs. However, it takes two long steps (Print Command and pulldown to Mail PDF command). I want to have one single keyboard shortcut for doing the Mail PDF.workflow command from within Word and not have to use the mouse at all. Any ideas?

    Maybe you can script it with AppleScript Editor (in Applications)? I'm no AppleScript guru, but since you did not get any other response, I thought I'd mention it.
    Get to the point where you want to use your keyboard command. Hit Record in AppleScript editor. If those actions are scriptable (not everything is), they will show up in the window. Hit Stop when you are done. You should be able to save the script as an application.

  • Any event for Print?

    I am implementing a Print functionality for charts. Currenly
    I am calling a method on the click of a button which does the
    PrintJob. But I would like to get rid of this button and use the
    default option for Print on the right click of a chart. Is there
    any such event of anything else from where I could call the
    function for print (which I have impemented) & get rid of this
    Button?
    Thanks in advance.

    Gordon:
    On page 11 of the How to Customize Printing Templates with Print Layout Designer document, this is what it says about the PLD Document Properties window, tab "Extension":
    To add DLL files to the template in order to enhance the functionality of the template, select the Extension tab.
    EXAMPLE: You can e-mail the document in addition to sending it to the printer.
    As far as I could see, the SDK documentation does not have any information about this feature... Any idea on where to look?
    Thanks,
    Joerg.

  • Changing the order for printing portfolio files in adobe acrobat 9 pro

    Does anyone know how to change the order for printing pdf files that are part of a portfolio in adobe acrobat 9 pro?  The documentation seems to say that it prints files alphabetically by filename rather than by the internal sort order.  This won't work for me. Any ideas? Thanks.

    Question1: No.
    Question2: No.

  • HP ePrint old printer e-mail address

    I had to reinstall wireless configuration to my printer and reenable HP ePrint services. That unfortunately also meant new unique printer e-mail address.
    I am aware that the old e-mail address is obviously locked out for security reasons for 6 months. How can I retrieve the old e-mail printer address sooner? I am using the same ePrint account as before, the same printer, from the same location. The old e-mail addresses should be enabled for the same accounts. It causes a lot of inconvenience to others using my printer.
    Thank you very much for your answer.
    I am using HP LaserJet Pro P 1102w mono Printer, Windows 7 64-bit.

    You must wait 6 months for it to be release again.   Just pick another email name for your adddress.
    Say thanks by clicking the Kudos Thumbs Up to the right in the post.
    If my post resolved your problem, please mark it as an Accepted Solution ...
    I worked for HP but now I'm retired!

Maybe you are looking for