cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
lou
lou
Level III

Using JSL to send emails

I'm trying to use JSL to send emails as part of a data retrieval query.  How do I embed a data table or Journal table into the body of my text message?

Thanks

18 REPLIES 18
SDF1
Super User

Re: Using JSL to send emails

Hi @lou,

 

  I did a search for Mail in the Scripting Index and found this:

Names Default To Here( 1 );
Mail( "test@example.com", "revelation", "JMP is great.", "$SAMPLE_DATA/Big Class.jmp" );

  I tested it out with the Alarm Script example and it send me a message. I did not attach any JMP file, and not sure if it will embedd in the email body, but it will at least offer to add an attachment. Should solve your problem.

 

Hope this helps!,

DS

lou
lou
Level III

Re: Using JSL to send emails

Hi DS,

Thanks for your reply.  Attaching is an alternative.  Still looking for a way to add this to the main message, whether by table, journal or picture.

Lou

 

SDF1
Super User

Re: Using JSL to send emails

Hi @lou,

 

  This was a great challenge, and I think I figured it out. Should be only about three lines of code.

 

Names Default To Here( 1 );
dt = Data Table( "My Data Table" ); //this defines whichever data table you're dealing with
tb=dt<<Get As Report(); //this generates a data table report
Mail("myemail@address.com", "subject", "The data is " || Eval(tb<<Get Text)); //Using the Get text command generates a list, i.e. {"..."} which can be evaluated in the Mail command because it has quotes around it

  I tested it on a data table of mine and it worked great. It even puts the text in a data table style/format. It is just text, but this should solve the original problem.

 

UPDATE: I went back and tested if you could add more text to the body and you can if you wrap the <<Get Text portion in an Eval() statement and  concatenate with ||. So, I think this can get more advanced and "complicated" by concatenating several Eval() portions, depending on the complexity of the automated script.

 

Hope this helps!,

DS

lou
lou
Level III

Re: Using JSL to send emails

Hi DS,

Thank you very much!!  This is what I needed!  I appreciate your help.

Lou

SDF1
Super User

Re: Using JSL to send emails

You're welcome. I also found out that if you include a \!n within quotations after your "opening sentence", you can have a carriage return before the data table is printed in the email.
Stefan
Level III

Re: Using JSL to send emails

Hi, how did you manage to add the carriage return, I've tried all options with \!n, but no success. Can you add an example please?

 

Cheers!

SDF1
Super User

Re: Using JSL to send emails

Hi @Stefan ,

 

  Using the "escape sequences", as they're called, can sometimes be a bit tricky. Sometimes they work as one would think they should, but other times they need to be invoked differently. It's kind of like :Column vs Column(dt, #), or As Column(). They all reference columns, but there are some cases where one is better than another.

 

  Anyway, you were wanting a specific example for the carriage return, here is one that works with a built in data table in JMP.

Names Default To Here( 1 );
Open( "$SAMPLE_DATA/Big Class.jmp" );
dt = Data Table( "Big Class" );
tb=dt<<Get As Report();
Mail("myemail@address.com", "dt names", "The data is "||"\!n"||Eval(tb<<Get Text));

  You don't have to have the extra concatenate || in there between "The data is " and !\n. You can instead write it as "The data is !\n" || Eval() and it'll work just the same. But, however you implement it, the !\n must be in quotations: "\!n" for it to be read correctly.

 

  One note that might be the reason you're having problems is the host operating system. If you're working in OS vs Windows, then the carriage return is different: CR vs CR LF, respectively. If you're on a Mac, the "\!n" won't work. Instead, you should use "\!N" with a capital N. When you use that, it insert a line break appropriate for the host operating system.

 

Hope this helps!,

DS

Stefan
Level III

Re: Using JSL to send emails

@SDF1  thanks for the quick reply, tried the few options you are recommending, no joy still. I am running on Windows, JMP 15.2.1

This is the excerpt from the email body...

The data is name age sex height weight...

SDF1
Super User

Re: Using JSL to send emails

Hi @Stefan ,

 

  That is really strange. I'm running JMP Pro 15.2.1 on W10 64-bit. This functionality is certainly not Pro dependent, so I can't imagine that's the case. When I run that code for the Big Class, I get this email out:

DiedrichSchmidt_1-1611852391900.png

 

  Did you copy/paste the code exactly, with only changing the email address? If the code was changed other than the email address, this could impact the formatting in the email. Do you have a screen shot of the code and email you receive from JMP?

 

DS