AppleScript To Save Messages As PDFs With Specific Naming Convention

I am looking for an Applescript that:
1: Prompts and allows the user to select one or more Apple Mail email messages from within Mail (10.4, 10.5, 10.6).
2: Prompts and allows the user to select a save-to folder.
3: For each message, saves it as a PDF file in the save-to folder, using the following naming convention for the PDF file:
"YYYY-MM-DD HH.MM.SS Email From FIRSTNAME LASTNAME - SUBJECT",
"YYYY-MM-DD HH.MM.SS Email To FIRSTNAME LASTNAME - SUBJECT",
where in the email date-sent stamp (if I am the sender) or date-received stamp (if I am the recipient):
YYYY = the year
MM = the two-digit month
DD = the two-digit day
HH = the two-digit hour (in 24-hour time)
MM = the two-digit minute
SS = the two-digit second
FIRSTNAME is the email sender's first name for email that I receive (or is the email recipient's first name for email that I send)
LASTNAME is the email sender's last name for email that I receive (or is the email recipient's first name for email that I send)
SUBJECT = the email's subject line
For example: 2010-04-10 16.32.48 Email From Kris Ryan - Status Of Payroll Updates.pdf
For example: 2010-04-10 16.33.55 Email To Sue Anderson - RE Status Of Payroll Updates.pdf (Colon omitted after "RE".)
4: For each attachment to the message, saves it as a PDF file in the same directory using the naming convention:
"YYYY-MM-DD HH.MM.SS Email From FIRSTNAME LASTNAME Z Attachment - NUMBER - FILENAME",
where:
YYYY-MM-DD HH.MM.SS Email From FIRSTNAME LASTNAME = as above
NUMBER = an integer representing the attachment number (1, 2, ...) sorted according to filename alphabetical order
FILENAME = the name of the file attached to the email, including its extension (.docx, .xlsx, etc.)
The letter "Z" sorts the attachment PDFs after its respective parent email in the directory.
For example: 2010-04-10 16.32.48 Email From Kris Ryan Z Attachment - 1 - List Of Suggestions To Moore.doc.pdf
For example: 2010-04-10 16.32.48 Email From Kris Ryan Z Attachment - 2 - Proposed Salary Adjustments.xls.pdf
For example: 2010-04-10 16.32.48 Email From Kris Ryan Z Attachment - 3 - Salary History.pps.pdf
Note: The email attachment may consist of a PDF or MS Office file (Word, Excel, Power Point); however, a smart implementation will be able to handle any attachment kind. If the attachment is a PDF file, then save it "as is" using the stipulated naming convention, without passing it through Distiller.
Thank you.
Kurt Todoroff

Well, that's quite a spec sheet.
Here's a start, you can easily edit the script to get what you need:
<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">
Set a Mail Rule to Save Message and Attachment to Desktop.
To save attachments to another another folder on the desktop (i.e. Attachments) create the folder and then
change tell application "Finder" to set pathToAttachments to (path to desktop folder as string) & "Attachments:"
using terms from application "Mail"
on perform mail action with messages theMessages
tell application "Finder" to set ptd to (path to desktop folder) as string
tell application "Finder" to set pathToAttachments to (path to desktop folder) as string
tell application "Mail"
repeat with theMessage in theMessages
set d_recd to date received of theMessage as string
set d_recd to ReplaceText(d_recd, ":", " ") of me
set d_recd to ReplaceText(d_recd, ",", " ") of me
set theText to content of theMessage
if theMessage's mail attachments is not {} then
repeat with theAttachment in theMessage's mail attachments
set theFileName to pathToAttachments & (theMessage's subject) & " (Attachment From " & (theMessage's sender) & " Sent " & d_recd & ")" & space & theAttachment's name
try
save theAttachment in theFileName
on error errnum
end try
end repeat
end if
set theFile to ptd & (theMessage's subject) & " (From " & (theMessage's sender) & " Sent " & d_recd & ")" & ".txt"
set theFileID to open for access file theFile with write permission
write theText to theFileID
close access theFileID
end repeat
end tell
end perform mail action with messages
end using terms from
on ReplaceText(theString, fString, rString)
set current_Delimiters to text item delimiters of AppleScript
set AppleScript's text item delimiters to fString
set sList to every text item of theString
set AppleScript's text item delimiters to rString
set newString to sList as string
set AppleScript's text item delimiters to current_Delimiters
return newString
end ReplaceText</pre>

Similar Messages

  • Save Forms Fields PDF with information un-editable

    We created a simple 5 form field PDF invoice for a client to edit and send out to customers. They want to be able to edit the fields, but then save the resulting PDF with the input information to be un-editable but the end customer they are sending the invoice to. Is this possible?

    Will the client be using Acrobat or just Reader? If just Reader, you can lock the fields after they are filled-in by making them read-only, which will require a script. You should also set the default value of each field to the current value of the field, which prevents clearing the form if the user resets the form. There's an older topic from several months ago that discusses this in more detail. If you can't find it, post again and I'll try.
    If they will be using Acrobat, a better approach is to flatten the form fields, which converts the field apperances to regular page contents, removing the form fields in the process. You can flatten fields with Acrobat using JavaScript, PDF Optimizer, or Preflight. Post again if you need help with this.

  • Unable to save files as pdf with CS5 AI

    What do I need to do to be able to once again save files as pdf with out freezing up AI

    are you using a MAC or a Windows machine??
    there is no other place to set your PDF exports--(there are workarounds-but that doesn't solve the base problem)  there should just be a choice in a drop down menu when you do a 'save as' and the PDF options window should open when you choose Adobe PDF
    you should 'consider' reinstalling Illustrator as it seems that you've somehow lost your presets for PDF--BUT--
    first--need to know what OS you're running--if you recently updated a 'MAC' (to Mavericks 10.9.x) that could be the problem and I don't know if CS5 is problematic with Mavericks--IF you're using a Windows machine--a reinstall may prove to be the solution.
    let me know what OS you're running...OK?
    this window 'should' get to this other window

  • The way to open 3D pdf with specific model selection from url link

    I guess this feature is not supported, but let me ask one thing.
    I am looking for the way to open 3D pdf with specific model selection from url link.
    For example, if the following link is opened, is it possoble to open 3d.pdf with automatic selection of "abc" model in the model tree? 
    http://example.org/3d.pdf#model=abc
    If it can be done by javascript, it's really helpful.

    Impossible. There are only very limited command-line options for the Acrobat Family and you cannot change them.

  • Transport with CTS+ : Naming convention

    Hi SDNers,
    I need your suggestion.
    This is wrt CTS+.
    My doubt is:
    I need to transport changes between the Dev, QA & Production system.
    I have a repository in Development system: Repo_Dev
    Now I want to create a repository in Quality / Production system, similar to Repo_Dev , but with different Repository names as Repo_QS /  Repo_Prod respectively.  My doubt is, will I be able to create the repositories in the Quality or Production systems with the name I want.... or is it because I am using CTS.. it will create a repository with the same name i.e Repo_Dev.
    With reference to the SAP document "Setup und Use the MDM Change Transport with CTS+ Transport Management Environment", my understading is to
    1. Create a repository in QS / Production side.
    2. Using the option "Create Transport Reference" , I will get a reference file of Repo_Dev.
    3. Then Import the reference file in the Repo_QS / Repo_Prod will result in synchronisation between all 3 (Repo_Dev, Repo_QS, Repo_Prod ) repositories.
    This way I can have the same Data modelling etc in all the 3 repositories, with the naming convention as required.
    If anyone has worked on it... please confirm it.
    Thanks & Regards,
    Priti Rani Patnaik

    Hi Priti,
    For transport with CTS+ you need to follow the steps which you have mentioned. You need to create a repository and then import the ref. in this repository. By doing so you are only importing the tables and fields present in your Dev repository. The sync between all three is only related to data modelling and it will not effect the name of reposiotry as you have already created a repository and I guess renaming of repository is not possible.
    I hope I am able to help you.
    Thanks & Regards
    Dilmit Chadha

  • Is possible to save a vector.pdf with smart object?

    Hi PS masters
    I am finishing a poster, fully created in shapes in illustrator. Due to customers request I was forced to do some color corrections so I decided to use my PhotoShop CS6.
    I imported vector files into my photoshop as smart objects, added some adjustments layer, few vector masks and I changed their layer style to get the finest result.
    When I finished my work in PS I tryed to save this as .pdf
    In my .psd there are shape layers, some groups and some adjustments layers with layer masks and changed Layer style to "color", one text layer and 3 smart objects imported from illustrator.
    I want to keep my image scaleable for bigger resolutions.
    ... So I was trying to save this file as Adobe PDF but I found that whole graphic in exported .pdf was converted to raster, besides the border, cut marks and that one text layer.
    I think that this is becuase of smart objects. (saving as .pdf without them works pretty good)
    Now finaly my question.  Is somehow possible to save this document from photoshop as vector.pdf? or is possible to import group of shapes from illustrator to photoshop as shapes in photoshop? no as smart objects.
    I am running out of time so I saved it as high res .Jpeg, but I want to know if this is somehow possible for future use or If I have to rather avoid that solution.
    Thank you very much for your reactions
    // I just thought if I can use InDesign for that. Will be included .pdf file as raster? or it will stay scaleable even with smart objects in it?

    I am sorry but I don't have vector files right now (I'm on another PC), but I can show you "old" version of a poster, where you can see parts of their structure

  • Scripting 'Save PSD as PDF with password security' and 'Open PDF with password security' issue.

    Hi!
    I'm now building an extension for Photoshop. The script (jsx) should save the active document as Photoshop PDF secured with a password. The PW is the same all the time and is set in the script. Then the script is to open the PDF with that same password. I need all this to protect the PDF from opening by a user, so that only the script has access to the file.
    I've googled a lot. I've seen a similar topic on this community dated as 2012. It's not answered. With an only comment saying that saving with a password seems to be possible via GUI and not via a script.
    Has anything changed since 2012?
    P.S. Illustrator .documentPassword and .requireDocumentPassword don't work in PS and ScriptListener still gives nothing :-/

    ScriptListener still gives nothing
    Which probably means the task is (still) not possible to achieve with Photoshop Scripting.
    Both Photoshop DOM and AM seem to have weaknesses/omissions that I would consider more relevant but if you regard the issue as crucial you may want to post a Feature Request over at
    Photoshop Family Customer Community

  • How do I save a document to a specific named file

    How do I save a new document to a specificly named file?

    You would use "Save" from the File menu and then give it a name.
    If you are trying to make a copy of an existing file and want to give it a new name, you would use "Save As".  But, if you are using one of Apple's latest applications, the ones that have "Duplicate" instead of "Save As" in the File menu, you have to Duplicate first then you save the duplicated file.  When you save it the first time, you can name it whatever you want.
    Was this what you were asking?

  • What is the PDF (book) file naming convention for iTunes?

    I need to re-import my PDFs after migrating from "Windows XP to Windows 7, as the PDFs were not included in the Libary XML.
    What should the PDF file names be so that when each is imported, it will reconize the Author and Title, and I won't need to manually
    edit these using "Get Info".   I tried <Author> - <Title>.pdf, with a space-hyphen-space betwwen Author and title, but that didn't work.
    I have "keep iTunes media folder organized" checked, so Author folders are auto-created.
    Thanks!

    When you add a PDF to iTunes it normally sets the filename as the book name. As far as I'm aware iTunes doesn't attempt to extract any other metadata from the PDF even if it is present. If you let iTunes organize your files then after setting the author and title it will move to ...\<Media Folder>\Books\<Author>\<Title>.pdf.
    tt2

  • How can I/Is it possible to silently print a PDF with specific print settings and obtaining the resulting job id (in windows at least)?

    Greetings,
    I have a specific application for Windows I'm developing where I need to silently print a PDF to a real printer.  The trick is I need to set specific printing preferences ... such as color/monochrome, # of copies, page size / source tray, etc.   The printer is always set to spool documents, and it is key that I know the job id (even if its already done printing) of the resulting print job.
    With windows APIs mixed in, I would imagine something like ...
    OpenPrinter(printername)
    StartDocPrinter(...)
    -----> some SDK call to print the document based on the handles I pass it...or perhaps one page at a time after I call StartPagePrinter()
    EndDocPrinter(...)
    ClosePrinter()
    I've been searching for something for days that would give me this sort of control, but I've been finding the documentation very difficult to find on silently printing a PDF through any means other than a command line which doesn't appear to give me the information or control I need.
    Is this possible with the Adobe SDK? 
    I've seen other posts accomplish this by changing the printing defaults for the printer, and then sending the job silently with a commandline.  This has two problems for me: 1) I still don't know the Job ID of the print job, and 2) I can't rely on the idea that other unrelated print jobs will not be sent while I'm processing the PDF ... making it difficult to use defaults as a means of controlling the settings without causing a lot of side effects.
    Even just a point in the right direction would be a huge help for how I could accomplish this.  
    Thanks a lot,
    Wayne

    You cannot uninstall Kit Kat from your phone. BTW what kind of phone do you have??

  • Can't save/update advanced action with specific slide set to jump to

    Using version 6.  Experienced with Advanced Actions, but no clue what's causing this.  If I include a "Jump to Slide" pointing at a certain slide in the project the action will not save or update.  I can point at any other slide except the one I need.  Nothing especially unique about the slide in question.

    When you save/update, does it give any error/prompt?
    Try creating a fresh script just with the action to jump to 'that' slide.
    Also check from a regular button, if you can set on Success to jump to the particular slide.
    Thanks,
    Anjaneai

  • Print folder of pdfs with specific settings

    I can create a desktop printer and drap 30 pdf files to it to print, but I want them to print half-size and 2-up.
    How can I set something like that up?
    thanks
    alan

    Another thing I tried was to save images into a pdf, but I don't know where the PDF is saved to...
    What is the order that I am supposed to do things in?
    What I have now is:
    1. Get specified Finder items (I have the items selected)
    2. Compress Images into PDF Document
    Now what? When I press play, it seems to work, but I don't know where the PDF is saved...

  • Does messages only work with specific software?

    ANSWER.

    Welcome to the Apple Support Communities
    Messages only works on Mountain Lion. See > http://support.apple.com/kb/HT5395?viewlocale=en_US&locale=en_US

  • Outbound Feeds with variable naming convention.

    All,
    We have a openhubs that we generate every month.
    Is there a way we can prefix with month & year, so the file name would look like, Month_Year_<file_name>.
    So when I execute the process chain, for the same outbound file "salesvolume.csv"
    for the month Jan 08, the file name is "jan08salesvolume.csv"
    for the month Feb 08, the file name is "feb08salesvolume.csv"
    so the file name has a variable part & a fixed path.
    Variable path is based ont month-year.
    Thanks
    kiran

    In the usage I've seen (C++), m is for "member". I'm pretty sure it's used in MFC, and it may come from the more general "Hungarian Notation" that also uses things like s for string, p for pointer (relevant in C/C++ but not Java), etc.
    I think this convention is pretty unusual in Java (I've never seen it), but I imagine there are a number of people, especially C++ programmers, who do use it.

  • Rename Table Name with proper naming convention

    Hi,
    I have many tables in DB & want to create a copy of those in another DB, but with proper name
    Means If My table is fgh_sub_record_file then It should rename like Fgh_Sub_Record_File in dynamic way.
    Pls Help.

    I am not sure of the reason for your intention. 
    But, An easy method would be the below:
    1. Get all the tables from DB1 to DB2(I assume you do this by backup/restore or export wizard)
    2. Create the below function in DB2.
    --Create the below function
    Create Function dbo.CapitalizeEachword ( @MyString varchar(max))
    Returns nvarchar(Max)
    As
    Begin
    Declare @XML xml
    Set @MyString = Replace(@MyString,'_',' ')
    Set @XML =CAST( '<root><rows><row>' + REPLACE(@MyString,' ','</row></rows><rows><row>')
    + '</row></rows></root>' As XML)
    Return
    REPLACE((
    Stuff (
    (Select ' ' + Col
    From
    Select Stuff(COL, 1,1, UPPER(Left(col,1))) As Col
    From
    Select X.p.value('row[1]','nvarchar(200)') As col
    From @XML.nodes('/root/rows') As X(p)
    ) X
    ) Y
    For XML Path('')), 1, 1, '')
    End
    3. Execute the below and verify the generated script and execute the script once concluded.
    --Test script to see your execution script(You may need to get the script and execute once verified)
    select 'exec sp_rename @objname=' + name + ', @newname=' + dbo.CapitalizeEachword(name)
    from sysObjects
    where type = 'U'

Maybe you are looking for

  • Training and Event Management

    Can anyone guide me as how to create Training Events in bulk through SAP? I am getting stuck in all ways.. I am not sure where exactly FIRMLY BOOKED flag is stored coz of which we are not able to develop any programs.. Please guide me if ther is any

  • Using usb to serial adaptor , how do I select this port from within labview

    Hi I am using a usb to rs232 adaptor , how can I select this port within labview as all I can see is the com 0, com 1, lpt ports . Any help appreciated Brett Snr Mining Engineering Technician Western Australian School of Mines Curtin University of Te

  • Problems reading from a file

    Hey, I have this file that I need to read so i can handle the contents. It was created in MSDOS and as I have very little experience in that topic, I wondered if anyone can point me in the right direction. I tried reading it as a ascii and binary fil

  • RegisterDatabaseChangeNotifications(Properties) error

    Hi, I have an unusual problem. When i try to register may DatabaseChangeNotification i get ORA-29972 error(user does not have privilege to change/ create registration) here is the code:           Properties prop = new Properties();           prop.set

  • [SOLVED] systemd, systemd-journal constantly at high CPU %age

    Hi all, I've switched a computer to systemd, and everything works nicely. The system is responsive and booting is even faster than before. Yay! However, both my CPU cores are constantly between 80% and 90%. When I do top in a terminal, I see systemd