cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
Ken_K
Level I

SMTP setup

Is it possible to setup a SMTP server to send email through SMTP relay using JSL?   See some options on SAS but not sure how to setup using JSL.  Thank you

21 REPLIES 21
jthi
Super User

Re: SMTP setup

In my opinion this type of issues are generally easier to debug within windows commandline or powershell as those are generally issues there, not in JMP (sometimes there are though issues with quoting in JMP).

-Jarmo
hcarr01
Level VI

Re: SMTP setup

Bonjour,

 

Est-il possible en utilisant votre méthode de modifier le corps du mail (dans -Body)?

Par exemple pouvoir écrire un mail avec des retours à la ligne et des espaces ?

 

Exemple du mail :

 

Bonjour,

 

Voici les informations que vous recevrez :

  - info1

  - info2

 

Merci

 

jthi
Super User

Re: SMTP setup

Have you tried if it works? If I remember it should but you might have to build the body according to Powershell rules (for example https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_quoting_ru... ).

 

When I wrote functions to send email in JMP using Send-MailMessage, I did find using -BodyAsHtml easier than just -Body.

-Jarmo
hcarr01
Level VI

Re: SMTP setup

Merci pour vos réponses !

 

Pouvez-vous montrer un exemple svp ?

J’ai déjà essayé quelque chose comme ceci

jthi
Super User

Re: SMTP setup

Names Default To Here( 1 );

str = "\[$body = '

Attached to this email
You will find Instructions

'
Write-Output $body
]\";

RP = Run Program(
	Executable("powershell.exe"),
	Options({str}),
	ReadFunction("text")
);
-Jarmo
hcarr01
Level VI

Re: SMTP setup

Existe-t-il la possibilité de le rajouter dans le script ci-dessous svp ?

Dans la partie « commandes » ?

 

Names Default To Here( 1 );

commands = {
	"Send-MailMessage -From 'email@address' -To 'email@address' -Subject 'Test mail' -Body 'Message goes here' -SmtpServer smtp.server.com\!n", 
	"exit\!n"
};

icommand = 0;

RP = Run Program(
	Executable( "PowerShell.exe" ),
	ReadFunction( Function( {this}, Write( this << Read ) ) ),
	WriteFunction(
		Function( {this},
			icommand++;
			If( icommand <= N Items( commands ),
				this << Write( commands[icommand] );
			,
				this << WriteEOF;
			);
		)
	)
);
jthi
Super User

Re: SMTP setup

Names Default To Here( 1 );

str = "\[$body = '

Attached to this email
You will find Instructions

'
Send-MailMessage -From 'email@address' -To 'email@address' -Subject 'Test mail' -Body $body -SmtpServer smtp.server.com
]\";


RP = Run Program(
	Executable("powershell.exe"),
	Options({str}),
	ReadFunction("text")
);
-Jarmo
hcarr01
Level VI

Re: SMTP setup

Super, merci pour votre réponse !

 

De la même façon, est-il possible de rajouter des caractères spéciaux dans le corps du mail ?

jthi
Super User

Re: SMTP setup

Send-Mailmessage has -Encoding parameter Send-MailMessage (Microsoft.PowerShell.Utility) - PowerShell | Microsoft Learn which could work. Or maybe you need those here-strings or convert to html and manage them there.

 

Edit:

Names Default To Here( 1 );

str = "\[$body = @'
Use a quotation mark, like ' or ", to begin a string.
!\!"#$%&'()*+,-./:;<=>?@[\]^`{|}~‒–—―‘’‚‛“”„‟…
'@
Write-Output $body
]\";

RP = Run Program(
	Executable("powershell.exe"),
	Options({str}),
	ReadFunction("text")
);
-Jarmo
hcarr01
Level VI

Re: SMTP setup

Merci pour votre réponse.

En parlant des caractères spéciaux, je parlais notamment des accents « é » ou « à ».