After following the Posting Guidelines, I’ve already searched for hours for code I could possibly borrow and twist to my needs. I’ve also thought it through the best I can not understanding AppleScript and Mail.app better.
Here’s the Big Picture:
After a total of four days (over two weeks), I’ve built a very simple Mail.app rule wrapped around two Automator applets (yes I know this is the Applescript OS X Forums… keep reading) which handles the following and works… it REALLY WORKS:
Automator Applet #1 - “Email to Text”
– Creates a text file from body of email (from an online form)
– Filters it twice due to what I believe to be (I really don’t know) invisible ASCII characters (¸Ë‡) handed over by the online form which errors out the merge. So I scripted a very rude section that selects text from the bottom of the body upwards to beginning of needed text, cuts and pastes into second plain text file.
Automator Applet #2 - “Merge and Create PDF”
– Merges second plain text file into a document and creates a PDF
– Creates and sends a New Email Message with PDF attached (currently recipient is hard coded)
– Finished up with some house cleaning (to prevent errors on next processing and just because I’m “that way”)
I’ll spare everyone the part where I almost hurt myself dancing around the room when this dream actually worked. Unfortunately, after testing it I realized it needs to be “fail-safe”. And I also realized that most, if not all of the above could be done as one long AS.
The major issue is that if more then one new message arrives at a time, the body of all new messages are combined into the first plain text file, which means that only the last new message (since the filter starts at the bottom of the text and moves up) is merged and the balance is ignored. This also means that the first new messages will receive a reply with the last new messages info and the others will not be processed at all.
Understand so far?
To simplify this I believe an Auto Responder script would work best. This would also correct the fact that the current New Email Message’s Recipient is hard coded into the script and I’d prefer the script have more flexibility.
With that said…
I’ve already borrowed an Auto Responder script:
http://email.about.com/od/macosxmailtips/qt/et022106.htm
… and wedged the Automator applets into it. And as I found out… it’s not that easy. The text file written is empty and the Automator applet runs but the PDF is never attached to the Auto Responder’s reply.
I also borrowed a Save Mail to Text script:
http://bbs.applescript.net/viewtopic.php?id=17655
… but switched over to Automator to handle this (see above ASCII issue)
So to recap… simple AS wrapper around two Automator Applets WORK… but…
I’d appreciate ANY help in creating a script in whole or in parts that:
– Loop for processing one new email message at a time
– Holds onto the senders email address
– Creates a clean plain text file of message (if not, I already have work around for this one)
– Run my Automator applets
– Replies to above sender with attached PDF
– And finally moves processed email to “Follow-Up” mailbox and tags read and flagged
– Repeat until no new email messages
And lastly… delays… each applet takes between 5-8 seconds to process.
I know it may look as if I’m asking alot… and I know I am, but did I mention IT REALLY WORKS? And basically, I looking for a very clean wrapper for my Automator Applets.
Thanks in advance, and thank you so much to everyone posting their code…I’ve learned faster by reviewing and play, it really helps!
I can’t code… but I can dream.
Model: Model: 1GHz G4 (12" PowerBook)
AppleScript: AppleScript: 2.1.1
Browser: Safari 419.3
Operating System: Mac OS X (10.4)