Here’s a quick and dirty bit of automation that I put together today that emails annotated PDFs from PDFPen via Google Drive with Hazel (It’s not that PDFPen can’t email files itself, it’s that there are some issues with my recipient on the other end of the email).
Once a week I go through all the purchase orders I’ve been emailed so I can authorise and send them back to my colleague in Finance. Ideally, I’d like to do this solely from my iPad, as all each PO needs is for me to write the category it comes out of and add signature.

PDFPen by a Smile Software is ideal for this. I load each attached PO into my PDFPen documents then delete the original emails. Then, in PDFPen, I write the code and load in my signature from Photo Stream (extra tip – I keep a separate Photo Stream album called ‘Essentials’ that contains my signature, company logo, iPad wallpaper etc. Things I frequently need  access to across all my devices.). Once I’m finished, I send it to my colleague by email.
 
Therein lies the problem. For some reason, the way iOS sends PDFs seriously doesn’t jive with how they are read in Outlook 2010 on her PC.
03
 
So I’ve tried to get around it my emailing the file to myself on my Mac and then forwarding it back on to her from Apple Mail. By the time all that is done, it’d be quicker to print it, sign it and walk it to her mail tray.
So I started thinking about other ways to automate it. PDFPen has other share options, including to Dropbox and Google Drive. I use Dropbox a lot for personal things but we use Google Apps at work, so I opted for sharing it to a specific folder in my Google Drive.
04
I still wasn’t satisfied with this as the goal is to get the file to my colleague via email as I didn’t want to add more steps to her workload by asking her to log onto Drive just to get any authorised POs I might have sent her. There must be a way of automating it further.
Hazel and watchfolders sprang to mind, and after some Googling around I found this bit of AppleScript that will send an attached file.

==================
set theAttachment1 to (POSIX path of theFile)
set subject_ to "Authorised PO"
set the_content to "Incoming automated message from Jim - authorised PO attached."
tell application "Mail"
    set newMessage to make new outgoing message with properties {subject:subject_, content:the_content & return & return}
    tell newMessage
        set visible to false
        set sender to "my.email@website.com"
        make new to recipient at end of to recipients with properties {address:"recipient.email@website.com"}
        make new attachment with properties {file name:theAttachment1} at after the last paragraph
        
        (* change save to send to send*)
        send --<<<<---------------- change save to send to send or send to save to save to drafts
        (* change save to send to send*)
    end tell
end tell
==================

05
So now, once I’ve finished my work on the purchase order, I share it to a watch folder in Google Drive, which Hazel then sends on on my behalf then files the PDF away into a subfolder.


Resources