The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > OmniFocus > OmniFocus 1 for Mac
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Omnifocus and VoodooPad Pro Work Flow Automation Thread Tools Search this Thread Display Modes
I have recently started using Omnifocus for Mac and iPhone after 'seeing the light' from David Sparks excellent videos. I have for many years kept all my working notes in VoodooPad Pro and I was looking for a way to make an efficient work flow between Voodoopad and Omnifocus.

The work flow I wanted was to be able to create Omnifocus actions within VoodooPad and for Omnifocus actions to be able to link directly to the specific VoodooPad page from which it was created.

I achieved this by creating a couple of VoodooPad python scripts that send OF actions from VoodooPad via google mail SMTP server and utilises the 'Send to Omnifocus' Apple Mail rules.

The first python script sends the page title as the OF action title and the page text as the OF action content. Note the content of the OF action includes a direct link back to the specific VoodooPad page.

The second script is similar to the first but only sends selected text to the OF action and also has a direct link back to the VP Page.

To set this up you need to do the following steps

1. Install Python 2.7. Note this is standard in OSX Lion but has to be installed for 10.6 and prior

2. Modify the scripts
- The gmailUser, gmailPassword and recipient variables must be set to your gmail account

3. In Voodoopad Pro
- Install the Python Plugin Enabler (google 'Extra plugins you can have for VoodooPad')
- copy the two scripts below to ~/Library/Application Support/VoodooPad/Script Plugins
- restart VoodooPad Pro
- The scripts will appear in the Voodoopad Pro Menu - Plugins -> Python Plugins

4. In Omnifocus
- Preferences, Mail, set 'Add Mail Rule to create Omnifocus actions' to ON
- set 'a subject starting with' to --- (three dashes)

5. OPTIONAL. You can add keyboard shortcuts for the scripts in System Preferences, Keyboard, Keyboard Shortcuts, Application Shortcuts. The exact menu names for the scripts are
Send Page to Omnifocus (python)
Send Selected Text to Omnifocus (python)

I use Control, Shift, Command and O for 'Send Page' script and Control, Shift, Command and T for the 'Send Selected Text' script

To use the scripts simply choose them from the Plugins menu in VoodooPad. If Apple Mail is running the OF action will appear in the OF Inbox. If Apple Mail is not running then when you start Mail it will open OF and add the action to the Inbox.

I hope this is of use to some Omnifocus users who also utilise VoodooPad. Both great products I use everyday.

Here are the Scripts

--------------------------------------------------------------------------
Send Page to Omnifocus.py
Code:
VPScriptSuperMenuTitle = "Python PlugIns"
VPScriptMenuTitle = "Send Page to Omnifocus (python)"

# Version 1.0. Allan Davies. Public Domain Script. Developed on VoodooPad Pro with Mac OS X 10.7.3 and Python 2.7.1
#
# This script sends the current voodoopad page (via google mail) to Omnifocus Inbox
# The omnifocus action, created in the inbox, has the page name as the action title and a clickable link
# directly back to the current voodoopad page together with the voodoopad page text
#
# Apple Mail and Omnifocus both need to be running for this workflow to operate effectively
# If Apple Mail is not running then the action does not flow through to Omnifocus until Apple Mail is opened
#
# Pre-requisites for this script are

# IN OMNIFOCUS
#
# (1) In Omnifocus Preferences under 'Mail' set 'Add Mail Rule to create Omnifocus actions' should be set ON
# (2) 'a subject starting with' should be selected and set to a value such as ---
#
# IN THIS SCRIPT
#
# (1)The omnifocus_mail_detector variable below must also be set to the 'subject starting with' value
# (2) gmailUser, gmailPassword and recipient must be set to your gmail account

# Known Problems
#
# (a) MINOR. If you are in Omnifocus and click the link the to the Voodoopad page and Voodoopad is not open then
#                 a message appears saying 'Sorry I could not find the document ...'. If you click OK then Voodoopad
#                 will open and go to the page

# Special thanks to http://code.hammerpig.com/ site for the email code and Gus Mueller, the creator of Voodoopad,
# for his advice

import smtplib
import unicodedata
import os
import mimetypes
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email.MIMEAudio import MIMEAudio
from email.MIMEImage import MIMEImage
from email.Encoders import encode_base64

def main(windowController, *args, **kwargs):

    # ----------------------------------------------------------------------------
    # user defined strings you will need to change before using this script
    # ----------------------------------------------------------------------------
    omnifocus_mail_detector='---'   #Defines the subject commencing string used by Apple Mail rule
                                               #that triggers the Mail 'Send to Omnifocus' rule 
    
    gmailUser = 'xyz@gmail.com'
    gmailPassword = 'mypassword'
    recipient = 'xyz@gmail.com'

    # ----------------------------------------------------------------------------
    # Send Mail routine
    # ----------------------------------------------------------------------------
    def sendMail(subject, text, *attachmentFilePaths):
        msg = MIMEMultipart()
        msg['From'] = gmailUser
        msg['To'] = recipient
        msg['Subject'] = subject
        msg.attach(MIMEText(text))
        for attachmentFilePath in attachmentFilePaths:
            msg.attach(getAttachment(attachmentFilePath))
        mailServer = smtplib.SMTP('smtp.gmail.com', 587)
        mailServer.ehlo()
        mailServer.starttls()
        mailServer.ehlo()
        mailServer.login(gmailUser, gmailPassword)
        mailServer.sendmail(gmailUser, recipient, msg.as_string())
        mailServer.close()
        print('Sent email to %s' % recipient)
      
    def getAttachment(attachmentFilePath):
        contentType, encoding = mimetypes.guess_type(attachmentFilePath)
        if contentType is None or encoding is not None:
            contentType = 'application/octet-stream'
            mainType, subType = contentType.split('/', 1)
            file = open(attachmentFilePath, 'rb')
        if mainType == 'text':
            attachment = MIMEText(file.read())
        elif mainType == 'message':
            attachment = email.message_from_file(file)
        elif mainType == 'image':
            attachment = MIMEImage(file.read(),_subType=subType)
        elif mainType == 'audio':
            attachment = MIMEAudio(file.read(),_subType=subType)
        else:
            attachment = MIMEBase(mainType, subType)
        attachment.set_payload(file.read())
        encode_base64(attachment)
        file.close()
        attachment.add_header('Content-Disposition', 'attachment',   filename=os.path.basename(attachmentFilePath))
        return attachment

    print 'sending page to Omnifocus Inbox'

    #Get unique id of current VP Page
    uuid=windowController.currentPage().uuid() 

    #Create url that links directly to the current VP Page
    pageurl='x-voodoopad-item://'+uuid

    #get the text of the current VP Page
    currentPage = windowController.currentPage()
    pageText = currentPage.dataAsAttributedString().string()

    #Set the email subject to the detector string and the current VP Page Title
    subject=omnifocus_mail_detector+currentPage.displayName()

    #Set the email body text to the VP Page Link and the contents of the current page
    text='VP Page Link:  '+'x-voodoopad-item://'+uuid+'\n\n'+pageText

    #encode the text to avoid Unicode problems
    mailtext=unicodedata.normalize('NFKD', text).encode('ascii','ignore')

    #send the mail via google SMTP server used in your gmail account
    sendMail(subject,mailtext)
    print 'Mail Sent....'
--------------------------------------------------------------------------
Send Selected Text to Omnifocus.py
Code:
VPScriptSuperMenuTitle = "Python PlugIns"
VPScriptMenuTitle = "Send Selected Text to Omnifocus (python)"

# Version 1.0. Allan Davies. Public Domain Script. Developed on VoodooPad Pro with Mac OS X 10.7.3 and Python 2.7.1
#
# This script sends the selected text on the current voodoopad page (via google mail) to Omnifocus Inbox
# The omnifocus action, created in the inbox, has the first 256 characters of the text selection as the action title and
# a clickable link directly back to the current voodoopad page
#
# Apple Mail and Omnifocus both need to be running for this workflow to operate effectively
# If Apple Mail is not running then the action does not flow through to Omnifocus until Apple Mail is opened
#
# Pre-requisites for this script are

# IN OMNIFOCUS
#
# (1) In Omnifocus Preferences under 'Mail' set 'Add Mail Rule to create Omnifocus actions' should be set ON
# (2) 'a subject starting with' should be selected and set to a value such as ---
#
# IN THIS SCRIPT
#
# (1)The omnifocus_mail_detector variable below must also be set to the 'subject starting with' value
# (2) gmailUser, gmailPassword and recipient must be set to your gmail account

# Known Problems
#
# (a) MINOR. If you are in Omnifocus and click the link the to the Voodoopad page and Voodoopad is not open then
#                 a message appears saying 'Sorry I could not find the document ...'. If you click OK then Voodoopad
#                 will open and go to the page

# Special thanks to http://code.hammerpig.com/ site for the email code and Gus Mueller, the creator of Voodoopad,
# for his advice

import smtplib
import unicodedata
import os
import mimetypes
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email.MIMEAudio import MIMEAudio
from email.MIMEImage import MIMEImage
from email.Encoders import encode_base64

def main(windowController, *args, **kwargs):

    # ----------------------------------------------------------------------------
    # user defined strings you will need to change before using this script
    # ----------------------------------------------------------------------------
    omnifocus_mail_detector='---'   #Defines the subject commencing string used by Apple Mail rule
                                               #that triggers the Mail 'Send to Omnifocus' rule 
    
    gmailUser = 'allangdavies@gmail.com'
    gmailPassword = 'gmail413'
    recipient = 'allangdavies@gmail.com'

    # ----------------------------------------------------------------------------
    # Send Mail routine
    # ----------------------------------------------------------------------------
    def sendMail(subject, text, *attachmentFilePaths):
        msg = MIMEMultipart()
        msg['From'] = gmailUser
        msg['To'] = recipient
        msg['Subject'] = subject
        msg.attach(MIMEText(text))
        for attachmentFilePath in attachmentFilePaths:
            msg.attach(getAttachment(attachmentFilePath))
        mailServer = smtplib.SMTP('smtp.gmail.com', 587)
        mailServer.ehlo()
        mailServer.starttls()
        mailServer.ehlo()
        mailServer.login(gmailUser, gmailPassword)
        mailServer.sendmail(gmailUser, recipient, msg.as_string())
        mailServer.close()
        print('Sent email to %s' % recipient)
      
    def getAttachment(attachmentFilePath):
        contentType, encoding = mimetypes.guess_type(attachmentFilePath)
        if contentType is None or encoding is not None:
            contentType = 'application/octet-stream'
            mainType, subType = contentType.split('/', 1)
            file = open(attachmentFilePath, 'rb')
        if mainType == 'text':
            attachment = MIMEText(file.read())
        elif mainType == 'message':
            attachment = email.message_from_file(file)
        elif mainType == 'image':
            attachment = MIMEImage(file.read(),_subType=subType)
        elif mainType == 'audio':
            attachment = MIMEAudio(file.read(),_subType=subType)
        else:
            attachment = MIMEBase(mainType, subType)
        attachment.set_payload(file.read())
        encode_base64(attachment)
        file.close()
        attachment.add_header('Content-Disposition', 'attachment',   filename=os.path.basename(attachmentFilePath))
        return attachment

    #Get unique id of current VP Page
    uuid=windowController.currentPage().uuid() 

    #Create url that links directly to the current VP Page
    pageurl='x-voodoopad-item://'+uuid

    #Detect any selected text and send as email
    document = windowController.document()
    textView = windowController.textView()
    selectedText = textView.textStorage().string().substringWithRange_(textView.selectedRange())
    if len(selectedText) > 0:
            print 'sending text selection to Omnifocus Inbox'
            #Set the email subject to the detector string and the selected text
            subject=omnifocus_mail_detector+selectedText[0:255]
            text='VP Page Link:  '+'x-voodoopad-item://'+uuid+'\n\n'+selectedText
            mailtext=unicodedata.normalize('NFKD', text).encode('ascii','ignore')
            print subject
            sendMail(subject,mailtext)
            print 'Mail Sent....'
    else:
        print 'No text was selected. Select some text and try again'
Scripts are provided as public domain

Regards
Allan
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Entrepreneurs! Looking for work flow suggestions isadore.braun Applying OmniFocus 2 2012-05-18 08:02 AM
Creating Flow with OmniFocus - Audiobook feedback request Kourosh OmniFocus 1 for Mac 5 2012-04-23 06:53 PM
Need help with Work Flow pash85 OmniFocus 1 for Mac 5 2011-08-23 03:22 PM
Creating Flow with OmniFocus carlbolduc OmniFocus for iPad 1 2011-06-22 10:59 PM
Book: Creating Flow with OmniFocus (Feedback request) Kourosh OmniFocus 1 for Mac 21 2011-05-28 01:50 PM


All times are GMT -8. The time now is 11:57 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.