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

AppleScript for moving mail messages to OmniFocus is creating duplicates in OmniFocus Thread Tools Search this Thread Display Modes
I'm trying to customize this script to import all flagged mail messages in to Omnifocus, then unflag and archive the message. It works, but it creates many duplicates in the Omnifocus inbox for some reason.

Here's the script:

on run

    tell application "Mail"

        set _inbox to "INBOX"

        set _msgs_to_capture to (messages of inbox whose flagged status is true)

        repeat with eachMessage in _msgs_to_capture
            set theStart to missing value
            set theDue to missing value
            set theOmniTask to missing value

            set theTitle to the subject of eachMessage
            set theNotes to the content of eachMessage

            set theCombinedBody to "message://%3c" & message id of eachMessage & "%3e" & return & return & theNotes

            tell application "OmniFocus"
                tell default document
                    set newTaskProps to {name:theTitle}
                    if theStart is not missing value then set newTaskProps to newTaskProps & {start date:theStart}
                    if theDue is not missing value then set newTaskProps to newTaskProps & {due date:theDue}
                    if theCombinedBody is not missing value then set newTaskProps to newTaskProps & {note:theCombinedBody}

                    set newTask to make new inbox task with properties newTaskProps
                end tell
            end tell

            set flagged status of eachMessage to false
            move eachMessage to mailbox "Archive" of account "memoryfailure"

        end repeat

    end tell

end run
I don't know the first thing about applescript, so any pointers would be great. I've tried cobbling together a few ideas from scripts I've seen in various places, but I seem to be missing something here that's creating duplicates.

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

All times are GMT -8. The time now is 08:26 AM.

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