<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: SMTP in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/RunProgram-context-closed-SMTP/m-p/713345#M89671</link>
    <description>&lt;P&gt;see&amp;nbsp;&lt;A href="https://community.jmp.com/t5/Discussions/Bug-or-Feature/m-p/673679#M86115" target="_blank"&gt;https://community.jmp.com/t5/Discussions/Bug-or-Feature/m-p/673679#M86115&lt;/A&gt; .&lt;/P&gt;
&lt;P&gt;When it works, you have a script window open the entire time. When it fails, no window is open, and JMP is using a temporary eval context which goes away at the end of the script.&lt;/P&gt;
&lt;P&gt;You could probably also work around the issue with a loop at the end of the script that waits for the runprogram to finish before allowing the script to finish. That won't work if you expect to run other JSL or platforms while runprogram works in the background, but approximately like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;RP=runprogram(...);
while(1,
 // check the message names, there might be another one you need too
 if(RP&amp;lt;&amp;lt;canread == 0 &amp;amp; RP&amp;lt;&amp;lt;canwrite == 0 , break() );
 wait(0.1);
)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;That way the eval context will persist until runprogram is done.&lt;/P&gt;</description>
    <pubDate>Wed, 03 Jan 2024 15:08:33 GMT</pubDate>
    <dc:creator>Craige_Hales</dc:creator>
    <dc:date>2024-01-03T15:08:33Z</dc:date>
    <item>
      <title>RunProgram context closed - SMTP</title>
      <link>https://community.jmp.com/t5/Discussions/RunProgram-context-closed-SMTP/m-p/713282#M89666</link>
      <description>&lt;P&gt;Bonjour à tous,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;À partir d’un serveur SMTP, j’essaye d’envoyer des pièces jointes à différentes personnes.&lt;BR /&gt;Le script fonctionne correctement.&lt;/P&gt;
&lt;P&gt;Le seul problème est que lorsque je rajoute «&amp;nbsp;!//&amp;nbsp;» au début de mon script pour qu’il s’exécute directement, j’obtiens l’erreur suivante :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hcarr01_0-1704272297533.png" style="width: 800px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/60155iC878FE9DDBCC414F/image-dimensions/800x34?v=v2" width="800" height="34" role="button" title="hcarr01_0-1704272297533.png" alt="hcarr01_0-1704272297533.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Voici le script que j’utilise :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;//!

Names Default To Here( 1 );

// modifier le type de codage dans le PowerShell (windows)
stringCommand = "$OutputEncoding = [System.Text.Encoding]::UTF8";


// paramètres du mail à envoyer
commands = {
	"Send-MailMessage -From '... -To '...' -Subject 'test' -Body 'test' -SmtpServer... -Attachment 'test...'", 
	"exit\!n"
};


// script exécution PowerShell
icommand = 0;

RP = Run Program(
	Executable( "PowerShell.exe", stringCommand, ShowWindow("Hide") ),
	ReadFunction( Function( {this}, Write( this &amp;lt;&amp;lt; Read ) ) ),
	WriteFunction(
		Function( {this},
			icommand++;
			If( icommand &amp;lt;= N Items( commands ),
				this &amp;lt;&amp;lt; Write( commands[icommand] );
			,
				this &amp;lt;&amp;lt; WriteEOF;
			);
		)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;FONT&gt;Merci de votre aide !&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jan 2024 12:01:13 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/RunProgram-context-closed-SMTP/m-p/713282#M89666</guid>
      <dc:creator>hcarr01</dc:creator>
      <dc:date>2024-01-04T12:01:13Z</dc:date>
    </item>
    <item>
      <title>Re: SMTP</title>
      <link>https://community.jmp.com/t5/Discussions/RunProgram-context-closed-SMTP/m-p/713345#M89671</link>
      <description>&lt;P&gt;see&amp;nbsp;&lt;A href="https://community.jmp.com/t5/Discussions/Bug-or-Feature/m-p/673679#M86115" target="_blank"&gt;https://community.jmp.com/t5/Discussions/Bug-or-Feature/m-p/673679#M86115&lt;/A&gt; .&lt;/P&gt;
&lt;P&gt;When it works, you have a script window open the entire time. When it fails, no window is open, and JMP is using a temporary eval context which goes away at the end of the script.&lt;/P&gt;
&lt;P&gt;You could probably also work around the issue with a loop at the end of the script that waits for the runprogram to finish before allowing the script to finish. That won't work if you expect to run other JSL or platforms while runprogram works in the background, but approximately like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;RP=runprogram(...);
while(1,
 // check the message names, there might be another one you need too
 if(RP&amp;lt;&amp;lt;canread == 0 &amp;amp; RP&amp;lt;&amp;lt;canwrite == 0 , break() );
 wait(0.1);
)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;That way the eval context will persist until runprogram is done.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jan 2024 15:08:33 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/RunProgram-context-closed-SMTP/m-p/713345#M89671</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2024-01-03T15:08:33Z</dc:date>
    </item>
  </channel>
</rss>

