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 2 
Send Topic Print
Sending an email (Read 17427 times)
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Sending an email
Reply #15 - Jan 20th, 2010, 3:13am
 
What info about the container and its contents do you want - can't really answer the question accurately from you without a clearer description.

In my example $MyMessage was just a notional user attribute. We could, instead use $Name(A Container) to insert the title of note 'A Container'.

Try to step back from the fixed task at hand an think in more general terms - you'll find the mechanism's you need will tend to become clearer.

To use runCommand, place it in the rule or action for a note or agent.  Unlike most action codes, it doesn't need a left side (i.e $SomeAttr=runCommand). For instance try placing this in a note's OnAdd:
  runCommand('printf "'+$MyMessage+'" | mail '+$Email(parent));
Put your email in the $Email attribute of the note. With that done, drop an note into the first note making it into a container; you'll get an email with the name of the dropped note.  Add another note to the container - get another email.
Back to top
 
 

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



Posts: 168

Re: Sending an email
Reply #16 - Jan 20th, 2010, 8:37am
 
Basically, I'm hoping to email a task list to myself every day.  

The container I'm hoping to email contains two agents--the structure is like this:

Today [container]
---Overdue [agent]
-------overdue task [alias]
-------next overdue task [alias]
---Next Actions [agent]
-------first task [alias]
-------second task [alias]

I've set up some templates so that if I export the container "Today", I get a nice bulleted list representing the outline structure above.  My intent is to email that bulleted list to myself every day to have a portable task list for when I am away from Tinderbox.

Here is the command I have been using (culled, in part, from the Email from Tinderbox article on the Eastgate site):

$result=runCommand('printf "'+exportedString("this",/Templates/EmailTemplate)+'" | mail '+$Email(parent))

This is in the OnAdd section of the note.  When I drop the "Today" container into this note, I get an email with the message:

/TemplatesEmailTemplate

If I change the code above to:


$result=runCommand('printf "'+exportedString(this,EmailTemplate)+'" | mail '+$Email(parent))

I get an email with the message:

EmailTemplate

I'm not sure where the problem is, because I'm having trouble debugging both the runCommand code and the exportedString code.  I'm guessing runCommand is working right since I'm getting an email.  I'm not sure where I'm going wrong with the exportedString code, since I'm basically copying the code from the article about emailing.  Maybe my template is set up wrong?  Or using internal templates (as opposed to text files as in the example) is mucking things up?
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Sending an email
Reply #17 - Jan 20th, 2010, 10:28am
 
OK, first test the exportedString feature in some other context, e.g. as a rule to set $Text to the result of exportedString(). Fix that first - if fixing is needed.

If exportedString output is OK as it is, then I believe you need to evaluate exportedString's contents before they are inserted into the runCommand.

Consider adding a new String attribute $MyExportString. Now changes your existing code to this sort of thing"

$MyExportString=exportedString("this",/Templates/EmailTemplate);$result=runComma
nd('printf "'+$MyExportString+'" | mail '+$Email(parent))


When code in an action operator outputs the code instead of the expected evaluated output, likely the operator isn't evaluating the code, so pre-evaluate the failing part into an attribute and use the attribute value instead of the failing code.
Back to top
 
 

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



Posts: 168

Re: Sending an email
Reply #18 - Jan 20th, 2010, 11:04am
 
Ok--the exportString is where I'm falling down.  I'm following the examples in the Tinderbox Way almost exactly, so not sure why this isn't working.

Here's what I have:

Task List
--Today
----Agent1
----Agent2
Templates
--List
--ListContainer

List is a template with this in the text:

<li>^title^</li>
^if(^get(ChildCount))
     <ul>
^justChildren(/Templates/List)
     </ul>
^endif

ListContainer is a template with this text:

^if(^get(ChildCount))
     <ul> ^justChildren(/Templates/List)
     </ul>
^endif

This produces exactly what I want when viewed in HTML view.

I put this code as a "rule" in the "Today" container

$result=exportedString("this",/Templates/ListContainer);

What I get in $result is:  /TemplatesListContainer

Where am I going wrong with the exportedString syntax?
Back to top
 
« Last Edit: Jan 20th, 2010, 11:04am by Derek Van Ittersum »  
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Sending an email
Reply #19 - Jan 20th, 2010, 1:24pm
 
Tried this in v5.0.1 and 4.7.1 and I think the problem is that exportedString() isn't functioning as documented as I understand it. My hunch is it got broken in the code parsing changes in v4.6.0. I think we need to check with support before trying to go further with exportedString() in the loop.

Update: I think the problem is actually that for some reason the operator doesn't work with internal templates. Help defines it thus:

Quote:
exportedString(note,templateFile)
exportedString(note,templateString)

The first form of exportedString takes a reference to a note and the name of a file in the HTML Export Template folder, and returns the result of applying the template to the note. The second form requires no external file; instead, its second argument is the template string itself.
exportedString(this,"^getFor(parent,Name)")
or
exportedString(this,$MyTemplate)


I think my aTbRef notes led me astray. I'll try and look at this tomorrow.
Back to top
 
« Last Edit: Jan 21st, 2010, 7:34am by Mark Anderson »  

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

User - not staff!

Posts: 5689
Southsea, UK
Re: Sending an email
Reply #20 - Jan 21st, 2010, 8:14am
 
After a lot of blind alleys, I think I have figured exportedString(item,template) as there are some syntax catches.

Parameter: #1
This is a case-sensitive text string, that may or may not be double-quote enclosed. The string should be: a note name, a path, an item designator. If this parameter contains spaces or commas I'd advise quotes: i.e. "More Stuff" not More Stuff.

Parameter: #2
This was harder to figure as there is a glitch (as at v5.0.1) - you can't use internal templates. For now you can only use external templates, though I'm sure that's not intended and this will get fixed ere long. This parameter can be one of 2 forms:
  • A template name. This must be double-quote enclosed case-sensitive string that is the file name (with file extension) of an external template. Do not try to use the full OS path to the template. The TBX must be set up to use an external template folder and the only way to do this is to make an external template the TBX default HTML template (Doc Preferences -> HTML -> 'HTML Template file'). Of course this means it is now the default for *all* your notes - probably not what you really want. For example, assuming an external reference is set and the template is called List.txt then you must set the parameter "List.txt". Using List, list.txt, "List", etc. or the full path to the file will all fail.
  • Attribute name, e.g. $EmailString. In this usage the parameter is a $-prefixed name of an existing string-type attribute. The attribute should contain code such as would be used in an export template. If editing such an attribute, don't be tempted to use a path with the note such as $Text(Other note). The latter fails as the attribute is not fully evaluated.


Stick to those rules and it should be OK!
Back to top
 
 

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



Posts: 168

Re: Sending an email
Reply #21 - Jan 22nd, 2010, 2:29pm
 
that did it!  thanks mark.
Back to top
 
 
  IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: Sending an email
Reply #22 - Jan 22nd, 2010, 4:24pm
 
Clarifying:

      exportedString(note,template)

The first parameter, note, designates a note.  It's typically a pathname or a designator like "this" or "parent".

The second parameter is either

a) the export template to be used, as a string -- e.g. "^title"

OR

b) a variable reference that contains the string,

OR

c) the name of an external template file.

In the future, we'll also allow the second parameter to refer to a path to a template note.
Back to top
 
 
WWW   IP Logged
Pages: 1 2 
Send Topic Print