cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
The Discovery Summit 2025 Call for Content is open! Submit an abstract today to present at our premier analytics conference.
Get the free JMP Student Edition for qualified students and instructors at degree granting institutions.
Choose Language Hide Translation Bar
View Original Published Thread

SMTP setup

Ken_K
Level I

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
ian_jmp
Level X


Re: SMTP setup

Take a look at the 'Mail()' command.

Ken_K
Level I


Re: SMTP setup

Thank you for the reply.   When I use Mail() function the email is sent through outlook client which blocks automatic email sending for me.   I'm trying to use SMTP routing to avoid using outlook client.   Is there a way to configure mail() function to use SMTP routing instead of Outlook client?

ian_jmp
Level X


Re: SMTP setup

Understood. Maybe there is some help in this earlier thread.

ih
Super User (Alumni) ih
Super User (Alumni)


Re: SMTP setup

If you are on windows here an option using powershell:

 

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;
			);
		)
	)
);

Info about the powershell utility:

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/send-mailmessage?vie...

 

Note that this requires powershell version 2:

https://docs.microsoft.com/en-us/powershell/scripting/windows-powershell/starting-the-windows-powers...

 

hcarr01
Level VI


Re: SMTP setup

Bonjour,
Comment je peux faire pour rajouter une pièce-jointe dans le mail svp ?

jthi
Super User


Re: SMTP setup

You can with most likely with all the different methods. For PowerShell (which I most of the time use) see the Microsoft documentation.

-Jarmo
hcarr01
Level VI


Re: SMTP setup

J’ai essayé avec la fonction « -Attachment » en suivant le modèle de ce lien : 

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/send-mailmessage?vie...

 

En indiquant le bon chemin d’accès, je ne reçois pas de mail. Je dois faire une mauvaise manipulation ou utiliser une mauvaise syntaxe.

 

avez-vous un exemple de script faisant appel à une pièce-jointe SVP ?

ih
Super User (Alumni) ih
Super User (Alumni)


Re: SMTP setup

I just tried adding this to the end of the string in my example above and it worked:

 -Attachments 'C:/file.txt'

The complete example would be:

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 -Attachments 'C:/file.txt'\!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;
			);
		)
	)
);
hcarr01
Level VI

Re: SMTP setup

I managed to make it work for a path without particular characters (Example: "è", "é"...)
Is there a special function for using special characters in messages and paths?

 

undefined

 

I get this error message in the registry

 

I added a line to modify the encoding type in PowerShell but this does not solve the problem:

 

undefined

 

undefined

 

 

I'm also trying to skip lines in the body of my email, I tried with different methods like "\n"... but it doesn't work.

This post originally written in French and has been translated for your convenience. When you reply, it will also be translated back to French .