回覆:SMTP看https://community.jmp.com/t5/Discussions/Bug-or-Feature/mp/673679#M86115 。
當它工作時,您會一直打開一個腳本視窗。 當失敗時,不會開啟任何窗口,且 JMP 使用臨時 eval 上下文,該上下文會在腳本結束時消失。
您也可以在腳本末尾使用一個循環來解決該問題,該循環等待運行程序完成,然後再允許腳本完成。 如果您希望在 runprogram 在背景運行時運行其他 JSL 或平台,那麼這將不起作用,但大致如下:
RP=runprogram(...);
while(1,
// check the message names, there might be another one you need too
if(RP<<CANREAD></CANREAD>
這樣,eval 上下文將持續存在,直到 runprogram 完成。
RunProgram 上下文已關閉 - SMTP大家好,
我嘗試從 SMTP 伺服器將附件發送給不同的人。
該腳本工作正常。
唯一的問題是,當我在腳本開頭添加“!//”以便直接執行時,出現以下錯誤:

這是我使用的腳本:
//!
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 << Read ) ) ),
WriteFunction(
Function( {this},
icommand++;
If( icommand <= N Items( commands ),
this << Write( commands[icommand] );
,
this << WriteEOF;
);
)
)
);
感謝您的幫助 !
自動化和腳本編寫