View Single Post
I am using Lotus Notes and OMNIFOCUS. I have created a combination of a Lotus Notes Agent and AppleScript Folder action to manage the interaction. It is not the worlds most advanced but does help with the worflow I follow.

I drag items into a folder that I have created within notes named "Followup". The agent, once per minute, scans the view and creates files (with URL's in the files) on the file system. It then moves the notes to another folder (Processed Followup) in notes. This is the notes portion.

I then have an applescript Folder Action for the folder that the agent writes to. It responds to new files by reading them and creating new inbox items. Combined I now just drag/drop the email from my Notes Inbox to the folder as I process my notes Inbox. The rest happens automatically. It has streamlined my email inbox processing a good bit.

Step 1:
Create the Agent:

Select your Mail Inbox within Notes.
Select the Memu Item Create -> Agent
Name the agent
Select Scheduled agent.
Click on Schedule and set to every minute.
Select Okay (Schedule dialog)
Select Close Window (Red circle) to get to the editor in notes for the agent

Select Initialize on the left side and replace the initial text with this agent script:

Sub Initialize
' On Error Goto ErrorCleanup
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim uniqueID As Variant
Dim curView As NotesView
Dim docCount As Integer
Dim notesInputFolder As String
Dim notesValidOutputFolder As String
Dim notesErrorOutputFolder As String
Dim outputFolder As String
Dim fileNum As Integer
Dim bodyRichText As NotesRichTextItem
Dim bodyUnformattedText As String
Dim subjectText As NotesItem

'''''''''''''''''''''''''''''''''''''''''''''''''' '''''
'INPUT OUTPUT LOCATIONS
notesInputFolder = "Followup"
notesValidOutputFolder = "Processed Followup"

'''''''''''''''''''''''''''''''''''''''''''''''''' '''''

Set db = session.CurrentDatabase
Set curview = db.GetView(notesInputFolder )
Set doc = curview.GetFirstDocument()


While Not ( doc Is Nothing )

Set subjectText = doc.GetFirstItem("Subject")
Dim msgText As String
Dim sender As String
Dim docDate As String
' docDate = doc.GetFirstItem("Date").text

sender = doc.From(0)
' GetFirstItem("From")
' Move to processed folder
Call doc.PutInFolder(notesValidOutputFolder)
Call doc.RemoveFromFolder(notesInputFolder)
' Dim BodyRichText As NotesRichTextItem
Set bodyRichText = doc.GetFirstItem("Body")
' Grab info for output file
bodyUnformattedText = bodyRichText.GetUnformattedText()

urlDatabase = "notes:///mail3/%YOURFILE%.nsf/0/" + Lcase(doc.UniversalID)
Dim openURL As String
openUrl = "toof://====" + urlDatabase + "====" + subjectText.Text

fileNum% = Freefile()
Dim fileName As String
fileName = "/Users/%YOURUSERNAME%/tools/notes_to_omnifocus/" & doc.UniversalID
Open fileName For Output As fileNum%
Print #fileNum%, "Subject: " & subjectText.Text
Print #fileNum%, "From: " & sender
Print #fileNum%, "Date: " & doc.ColumnValues(9)
Print #fileNum%, "URL: " & urlDatabase
Print #fileNum%, bodyUnformattedText
Close fileNum%

Set doc = curview.GetFirstDocument()

Wend


End Sub

<COPY UP UNTIL BUT NOT INCLUDING THIS LINE>
NOTES:
Replace %YOURFILE% with the name for your mail file. Replace the MAIL3 just before with the correct mail location as well.

Replace %YOURUSERNAME% with your user name on the mac (which matches your home directory name.

The above agent expects you to have a folder under your user diretory of
Users/%YOURUSERNAME%/tools/notes_to_omnifocus you must create the directory tools and notes_to_omnifocus or change the directory name in the agent to something else as desired.

The above agent expects you to place email in the "Followup" folder in notes for processing. And it will place the email into the "Processed Followup" folder when it completes. You must create these folders and should use the folder design from your inbox. You can also choose different folder names.


Folder Action Script:
If you have not done so before you will need to create the directory
Library/Scripts/Folder Action Scripts

This is under your user directory.

Then open the AppleSript Editor (Applications -> Utilities)
Paste the following into the empty script window:

on adding folder items to this_folder after receiving these_items

repeat with i from 1 to number of items in these_items

set this_item to item i of these_items

set readfile to open for access this_item

set fileContents to (read readfile)

close access readfile

set Pos to offset of "From:" in fileContents
set theSubject to characters 1 thru (Pos - 2) of fileContents as string
set theNote to characters (Pos) through end of fileContents as string


tell front document of application "OmniFocus"
make new inbox task with properties {name:theSubject, note:theNote}
end tell


end repeat

repeat with i from 1 to number of items in these_items

set this_item to item i of these_items

-- tell application "Finder"
-- delete the this_item
-- end tell


end repeat

end adding folder items to


<COPY UP UNTIL BUT NOT INCLUDING THIS LINE>

Choose Save as and name this omnifocusnotes. Place this under the Library/Scripts/Folder Action Scripts directory.

Now use finder to locate the folder notes_to_omnifocus. Which should have been created earlier when setting up the notes agent. Right click on the folder and select services -> Folder Action Setup...

You should see a list of actions. Scroll down and select omnifocusnotes (the name you used in the apple script editor)

Okay. You should be done. If necesary insure that your local notes setup has running scheduled agents configured. Go to Lotus Notes->Preferences and choose Basic Notes Client Config. Insure that the "Enable Local Scheduled Agents" is selected.


Now go move some email into your new Followup Folder. Watch as this turns into inbox items. And they have URL:s back to the original email in notes. And the email is moved to the processed folder for you.

Please post if you have problems/etc. Enjoy