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 Extras
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Text entered in AppleScript prompt getting converted to some Asian characters Thread Tools Search this Thread Display Modes
I am using Mail Act-On with Apple Mail to send emails to my OmniFocus inbox. I use a key command (courtesy of Mail Act-On) to fire off a series of actions, one of which is to run an AppleScript.

I have been using a modified "Send to OmniFocus" AppleScript and it has been working well, but it can only take the subject of the selected email and put it in the title of the OmniFocus item.

I want to be able to change the title of the item before it is added to OmniFocus, so I modified the script a bit to display a dialog into which I can enter a different title for the item.

Everything works great except that the text that is entered somehow gets converted to Asian characters and so is totally unreadable by mono-lingual little old me.

I can't imagine why this could be happening, but then, I'm an AppleScript novice. So, I turn to you and ask, "what's wrong with this picture?"

Code:
using terms from application "Mail"
	on perform mail action with messages theMessages
		tell application "Mail"
			
			repeat with eachMessage in theMessages
				set theStart to missing value
				set theDue to missing value
				
				set theTitle to the subject of eachMessage
				set theNotes to the content of eachMessage
				set theSender to sender of eachMessage
				
				set itemTitle to theTitle
				
				-- Display dialog to allow user to specify the Title for the new OmniFocus Inbox item
				try
					set itemTitle to display dialog "Item title" buttons {"Cancel", "Save"} default button "Save" cancel button "Cancel" default answer (theTitle)
				on error number -128
					set userCanceled to true
				end try
				
				set theCombinedBody to "Created from message:%3C" & message id of eachMessage & "%3E" & return & "From: " & theSender & return & return & theNotes
				
				tell application "OmniFocus"
					tell default document
						set newTaskProps to {name:itemTitle}
						--						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
			end repeat
		end tell
	end perform mail action with messages
end using terms from
I don't know if you need Mail Act-On to even test this, but any suggestions as to why this might be happening (or even better, a solution) would be most appreciated!

Thx
 
Solution found. Is this useful? How could it be improved?

Code:
using terms from application "Mail"
	on perform mail action with messages theMessages
		tell application "Mail"
			
			repeat with eachMessage in theMessages
				set theStart to missing value
				set theDue to missing value
				
				set theTitle to the subject of eachMessage
				set theNotes to the content of eachMessage
				set theSender to sender of eachMessage
				
				try
					set itemTitle to the text returned of (display dialog "Item title" buttons {"Cancel", "Save"} default button "Save" cancel button "Cancel" default answer theTitle)
				on error number -128
					set userCanceled to true
				end try
				
				set theCombinedBody to "Created from message:%3C" & message id of eachMessage & "%3E" & return & "From: " & theSender & return & return & theNotes
				
				tell application "OmniFocus"
					tell default document
						set newTaskProps to {name:itemTitle}
						--						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
			end repeat
		end tell
	end perform mail action with messages
end using terms from
Here is the finished script: http://bit.ly/11xwgfM

Put it in ~/Library/Application Scripts/com.apple.mail/

I was having some problems getting the Mail Act-On rules to all work within a single rule, so at their suggestion I've broken the actions into who separate rules to move the message and then run the script.

Step 1 Runs the applescript then calls the second rule


Step 2 Files the message in an Action mailbox
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes



All times are GMT -8. The time now is 02:23 AM.


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