Welcome, Guest. Please Login
Tinderbox
  News:
IMPORTANT MESSAGE! This forum has now been replaced by a new forum at http://forum.eastgate.com and no further posting or member registration is allowed. The forum is still accessible via read-only access for reference purposes. If you wish to discuss content here, please use the new forum. N.B. - posting in the new forum requires a fresh registration in the new forum (sorry - member data can't be ported).
  HomeHelpSearchLogin  
 
Pages: 1
Send Topic Print
Delayed sending of email from Tinderbox? (Read 21904 times)
Rob Forsyth
Full Member
*
Offline



Posts: 63

Delayed sending of email from Tinderbox?
Sep 21st, 2008, 5:32pm
 
I am exploring the feasibility of using TB in a team-working setting to where tasks from an outline are assigned to individuals. I would like then to be able to email to each individual a reminder of their assigned tasks collected by Agent. I see the "sendmail" example in the TB documentation but I am under the impression that if the computer is not connected to the network at the time "sendmail" is invoked (which is the case in this situation) it will fail. I'm sure there are ways of achieving off-line storage of mail and later distribution through Terminal command-line wizardry but it would be beyond me. I'd be more confident of a solution using Apple Mail so I could see the messages sitting in the outbox! Is this possible e.g. by AppleScript?
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Delayed sending of email from Tinderbox?
Reply #1 - Sep 21st, 2008, 5:59pm
 
A suggestion (feasibility is beyond my command line skills) but might TB not call a a script that tested for an active email connection and only send the email if one was found. Otherwise, a date attribute would be reset for N hours/day/etc before the process tried again. That might keep the process entirely within TB.
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: Delayed sending of email from Tinderbox?
Reply #2 - Sep 21st, 2008, 9:13pm
 
Another approach: have Tinderbox call a script that tells mail.app to compose a new message with appropriate content and recipient.  The message would then be sent later, when the sender is connected and checking their mail.
Back to top
 
 
WWW   IP Logged
Rob Forsyth
Full Member
*
Offline



Posts: 63

Re: Delayed sending of email from Tinderbox?
Reply #3 - Sep 22nd, 2008, 4:17am
 
Mark (B) -

Thanks. Am I right in thinking running an AppleScript can only be done manually by opening a note with the script attached? Can an AppleScript be run as an agent action? I would also appreciate pointers as to how the MailTo address, subject and content of the email message are passed to Mail from the relevant note attributes
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Delayed sending of email from Tinderbox?
Reply #4 - Sep 22nd, 2008, 4:55am
 
Re running of AppleScripts, see this aTbRef page and this TBWiki page.

I don't think TB can pass app data as parameters to an AppleScript, especially one auto-opened by TB (maybe that's a feature request). Therefore, it is my assumption (not tested) that you may need to revert to using a command line to call the AppleScript (or further CL script) as that way you can pass out TB data need for your email. Using a TB runCommand() call would make it easier to have one AppleScript (external to TB) calling Mail and making the emails with a generic CL being used by as many TB notes as required to call the scripts with differing parameters (e.g. addressee name, subject, etc.). Sorry I don't have actual code for this idea.

Regards

Mark
Back to top
 
« Last Edit: Sep 22nd, 2008, 4:58am by Mark Anderson »  

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: Delayed sending of email from Tinderbox?
Reply #5 - Sep 22nd, 2008, 10:25am
 
You can run Applescript scripts from the command line, and so from runCommand() in actions.  Using runCommand, you can pass whatever additional information you wish via stdin.

http://www.hoboes.com/NetLife/AppleScript/AppleScriptandtheCommandLine.html

http://www.macosxhints.com/article.php?story=20050523140439734

http://developer.apple.com/documentation/Darwin/Reference/Manpages/man1/osascrip...

Back to top
 
 
WWW   IP Logged
Rob Forsyth
Full Member
*
Offline



Posts: 63

Re: Delayed sending of email from Tinderbox?
Reply #6 - Sep 22nd, 2008, 4:23pm
 
Would there be any chance of an illustrative example, say for an OnAdd action that sent a message to an $Address with $Subject provided by the added note, with its $Text as content?

Thank you everyone
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Delayed sending of email from Tinderbox?
Reply #7 - Sep 22nd, 2008, 7:22pm
 
Make a script 'Mail.scpt' in your /Documents/ folder. Add this code:
Code:
on run argVals
	tell application "Mail"
		set theNewMessage to make new outgoing message with properties {subject:item 1 of argVals, content:item 2 of argVals, visible:false}
		tell theNewMessage
			make new to recipient at end of to recipients with properties {address:item 3 of argVals}
			send
		end tell
	end tell
end run 


Now the container's OnAdd action is:
Code:
ClResult=runCommand("osascript ~/Documents/Mail.scpt '"+$Name+"' '"+$Text+"' '"+$Email+"'") 


ClResult is a user attribute needed to take the return value of runCommand(). To map to your question $Email -> your $Address and $Name -> your $Subject.

(Tested in v4.5.1)
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Rob Forsyth
Full Member
*
Offline



Posts: 63

Re: Delayed sending of email from Tinderbox?
Reply #8 - Sep 23rd, 2008, 7:07am
 
Mark A's code as suggested as the Action of an Agent (recalling that the hope was to be able to use Agents to collect tasks assigned to different individuals and send them reminder emails) works well but remember to turn off Automatic Updating of Agents or else messages breed like rabbits!

Thanks again this is a great app and a wonderful support community
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Delayed sending of email from Tinderbox?
Reply #9 - Sep 23rd, 2008, 10:14am
 
Quote:
but remember to turn off Automatic Updating of Agents or else messages breed like rabbits!

Yikes - good catch!  I was - as you may guess - testing using a note container so agent updates didn't show up as an issue.

The Mail AS 'outgoing message' has other properties one might use - like making the sender a special address indicating TB as the sender and helping with mail filtering on receipt. You can also set a signature. If Mail isn't open this will open it but if visible is set to 'false' you won't see a message window which is most likely what you'll want.

For those new to command line (CL) work, in my action the double quotes are effectively being used to tell TB the pieces to put together and the single quotes are wrapping the arguments being passed to the CL. The latter avoids things like spaces/line returns confusing parsing of the CL when being run.


Back to top
 
« Last Edit: Sep 23rd, 2008, 10:15am by Mark Anderson »  

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Rafter T. Sass
Full Member
*
Offline



Posts: 100
Burlington, VT
Re: Delayed sending of email from Tinderbox?
Reply #10 - Sep 28th, 2008, 1:15am
 
How could I modify this to send just the children of a note? Would ^justChildren as the text do it?

Here is my application:
I have a To Do List agent, that collects the tasks that I'm focusing on today (ToDoList=true).

When I want to send my to do list to my ipod touch, for errands 'n' such, I just check the Key Attribute "MailtoTouch" in @To Do List "true."

My mailer agent mails each child of @To Do List to my dedicated to-do email account, and then sets "MailtoTouch" to false.

It seems like what has been laid out already is very close to this, but I don't know if I'm missing some complexity. The scripting is way over my head, alas.


Back to top
 
« Last Edit: Sep 28th, 2008, 1:16am by Rafter T. Sass »  
raughter   IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Delayed sending of email from Tinderbox?
Reply #11 - Sep 28th, 2008, 4:09am
 
Why not make an agent that finds notes inside the list. Try this as the agent query:
  #inside(@ToDo List) & ToDoList
Now use my emailing action as the agent's action adding ToDoList = false to the end of the action.

The #inside bit limits the scope of the agent's querying to just the To Do list and it's contents within which it then only selects items if/when ToDoList is true. If the state of ToDoList has other importance in your TBX, you might consider adding an extra Boolean user attribute just to flag items to be found and emailed.
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Pages: 1
Send Topic Print