Jump to content
Sign in to follow this  
sgasch

How do I specify multiple names in mail to field in XSLT?

Recommended Posts

Once I returned to my work environment, I was able to get the email to work once again (reference topic of getting email to work in different environment), except for the fact that I am unable to specify more than one email address in the toemail field (i.e., it works with only one recipient).

I have tried the following, to no avail:

;

blank space

paragraph marker

Any idea what the magic separator should be???

Share this post


Link to post
Share on other sites

The FMSA CWP Guide, p. 66, is clear how one can send e-mails to additional recipients:

recipient1@host1?from=sender@sendinghost&to=recipient2@host2&to=recipient3&host3&to=...

Share this post


Link to post
Share on other sites

Does this mean that I can't just define a FMP field like toemail with separators of some kind? Most of my systems have several recipients which are dynamically created, so it would not be possible to put them in the XSLT. In many cases, there are more than 20 recipients, all different for different records.

Share this post


Link to post
Share on other sites

No no, this can be done easily.

Let's assume you have your recipients in a related table to_recipients in separate records.

Let's assume also that the current record is stored in a variable current-record.

Let's assume further that you have a portal in your layout with table to_recipients and field to.

Then you can use the following code:










&to=









concat() does what it says: it concatenates strings.

Also the other case is possible: All the recipients in one field, separated with commas.

Define one calculation field which holds the first recipient.

Define another calculation field that takes all the remaining recipients and replaces the commas with "&to="

Use these fields and the concat() function in fmxslt:send_email

Share this post


Link to post
Share on other sites

Where is the Code that should be in the box?

I will try your other suggestion and see if I can get it to work.

Thanks.

Share this post


Link to post
Share on other sites

I think I am close, but the email does not seem to go to the send recipient. Here is my code:

select="fmxslt:send_email(concat($toemail,'?from=mscm@eos.nasa.gov&cc=sgasch@csc.com&subject=',$subject,$toemailrest),$emailWaivbody)"/>

I think that I put the $toemailrest variable in the wrong place.

What do you think?

Shirley

Share this post


Link to post
Share on other sites

I think you need to specify the first recipient separately. That is

fmxslt:send_email( concat( $first-recipient, '?', $other-recipients, ... )

First recipient does not need to have ‘to=’ prefix; others must.

Offtopic: is there a way to receive notifications from this forum by email? Some time age there was a ‘subscription’ feature, but now it's missing and I simply cannot track my posts and replies.

Share this post


Link to post
Share on other sites

I did put the first recipient first and used the "to=" only for the second, but the second never got the email (and I got no error message)???

select="fmxslt:send_email (concat($toemail,'?from=m scm@eos.nasa.gov&cc=sgasch@csc.com&subject=',$subject,$toemailrest),$emailWaivbody)"/>

By the way, when I post a message, it sometimes seems to add in spaces in the body of the xslt.

Any idea why the second recipient ($toemailrest) got nothing?

Share this post


Link to post
Share on other sites

When I put a literal string in the fmxslt, as in:

select="fmxslt:send_email(concat($toemail,'?from=mscm@eos.nasa.gov&cc=sgasch@csc.com&subject=',$subject,'&to=sgasch@sindbad.gsfc.nasa.gov&to=bmachtey@csc.com'),$emailWaivbody)"/>

both of the other recipients got email.

However, when I put in the same thing in a field, they got nothing:

select="fmxslt:send_email(concat($toemail,'?from=mscm@eos.nasa.gov&cc=sgasch@csc.com&subject=',$subject,$toemailrest),$emailWaivbody)"/>

$toemailrest = '&to=sgasch@sindbad.gsfc.nasa.gov&to=bmachtey@csc.com'

I think that I am close, but I really need to figure out why the same thing in a field does not work (no error message, just no email).

Please HELP!!!!

Share this post


Link to post
Share on other sites

Hmm. The only thing I'd try to check is that the $toemailrest variable contains exactly the text you want, i.e.

&to=sgasch@sindbad.gsfc.nasa.gov&to=bmachtey@csc.com

But I figure you probably did this already. So I'm puzzled ???

Share this post


Link to post
Share on other sites

Hmm. It could be a problem of output-escaping, i.e. that the & are replaced by & amp; in the XML result tree, and hence the & separator is not recognized anymore.

You may try to do the following when defining the variable toemailrest:








Share this post


Link to post
Share on other sites

Hi,

I did specify toemailrest as a variable, but nothing changed.

Could it be the version of the Server that I am using (it is actually FMP7 Server with FMP7 Developer with an extended license to do testing)?

I am puzzled as well as to why this does not work.

Once again, here is the excerpt from XSLT:

select="fmxslt:send_email(concat($toemail,$toemailrest,'?from=mscm@eos.nasa.gov&cc=sgasch@csc.com&subject=',$subject),$emailWaivbody)"/>

As far as toemailrest is concerned, the field is defined as:

'&to=sgasch@sindbad.gsfc.nasa.gov&to=bmachtey@csc.com'

I have tried various combinations for defining toemailrest, but nothing except for a direct definition (i.e., not in a variable) works.

Share this post


Link to post
Share on other sites

Martin,

Is this what you meant?

Hopefully you meant something else, but the above didn't work either.

Share this post


Link to post
Share on other sites

Please post your code here, the XSLT file and the FM file (I need only one record with an example address, so have not to bother about data protection).

Share this post


Link to post
Share on other sites

The MMEmailrest field in the record that I sent you (in WebWaivers) was:

&to=sgasch@sindbad.gsfc.nasa.gov

Are you talking about the field in the XSLT???

Share this post


Link to post
Share on other sites

The problem was not the MMEmailrest field. The XSLT code is ok and can even be made shorter:

KB article 3604 . These things you can debug in the XSLT by adding the following line right after the body tag:








The problem is, that the MMEmailbeg field (and similar fields) was stored as global.



Global fields in a file hosted by FMS(A), however, behave differently than in a non-shared solution. In a hosted scenario, global fields are stored per client, i.e. each client can have a different global field value, and the host does not update their values.  The initial value of the global field is taken from the host and is the one that was set when the file was uploaded to FMS(A). In your case it was empty at this moment, that's why fmxslt:send_email did not work: it had an empty $toemail address. 



See  



This displays the fmresultset XML tree, and one can check which fields are on the layout and which values they carry.

The best ist, you define these e-mail fields as standard text fields, or, to save disk space, use a separate table (with only one record) having these fields.

Share this post


Link to post
Share on other sites

Martin,

I tried your suggestion, but still got an error 10202 (SMTP field error). When I removed the $toemailrest field, it worked. I tried the field with and without an extra set of single quotes, but to no avail.

I also looked at the debug info. Is there any way to see what the send_email string actually translates to???

I have attached the debug info from the one that failed.

I think we are close, once again, but something is still not quite right.

By the way, I should have mentioned before that I had gotten the email to work, but with no $toemailrest field showing up in the mail message. The $toemail was OK, though I'm not sure how - maybe because the environment that I am using is my own machine, with the test license that was sold with FMP 7 Advanced.

What now?

debug.zip

Share this post


Link to post
Share on other sites

Hi Martin,

I removed the apostrophes, but that didn't help. When I put the $toemailrest variable after the $toemail variable, I got a "to field error " (10202). I then put it after the subject and got a "SMTP field error" (10203). Here is the second example:

select="fmxslt:send_email(concat($toemail,'?from=mscm@eos.nasa.gov&cc=mscm@eos.nasa.gov&subject=',$subject,$toemailrest),$emailWaivbody)"/>

$toemailrest is now defined as:

&to=sgasch@sindbad.gsfc.nasa.gov

I just thought I would try one to see if that worked.

If there was a way to see the expansion of the rest of the send_email, maybe we got figure out the problem!

Share this post


Link to post
Share on other sites

I don't understand - yesterday I uploaded your db and the stylesheet to our server, and after filling out MMEmailrest and MMEmailbeg correctly and defining them as standard text fields everything worked; you got the confirmation e-mail.

Oh yes, change & amp; to & in MMEmailrest.

Share this post


Link to post
Share on other sites

It WORKED!!!!!

The documentation seems to indicate that you always use the "&", not just the "&". By the way, I did see the email that you sent, but thought it was one of the many that I have been sending for the past few days, so I didn't realize that you had sent it.

Thank you, thank you, thank you for all your help and patience with this problem!!!

Now I can complete my updates to my systems, since this was one of the last hurdles to get over.

I do wish that the documentation for this function was better. I guess that's why some people have not begun to use XSLT, but went to PHP instead. I looked at that, but didn't want to rewrite so many of my pages.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

By using this site, you agree to our Terms of Use.