BookmarkSubscribeRSS Feed
hrmayers
Calcite | Level 5

How do I connect the data step creating emails to the outside world?  Running under VMWare.

4 REPLIES 4
Jagadishkatam
Amethyst | Level 16

hope this helps

filename mailbox email;

data _null_;

file mailbox to='emailaddress@x.com'

subject='test mail';

put "hello";

run;

thanks,

Jag

Thanks,
Jag
hrmayers
Calcite | Level 5

Sorry I didn't make it clear that I was trying to send from inside SAS University Edition under VMWare.  The code below runs but the email never show up.  How do I connect to an email server outside of SAS?

thanks, Howard

data mails ;
  length mail_id $50. ;
  mail_id = "howard@mayers.org" ;
  output ;
  mail_id = "hr@dba.ws" ;
  output ;
  mail_id = "howard@get90team.com" ;
  output ;
  stop ; 
run ;

proc sort ; by mail_id ; run ;
proc print ; run ; 


%macro send_email ;

filename hm_mail email lrecl=32000 type='text/html' ;

data _null_ ;
set mails END=EOF ;
by mail_id ;
file hm_mail ;

retain numofusers 0 ;
if first.mail_id then do ;
  numofusers=numofusers+1 ;
  If mod(numofusers,300) = 0 then Timer=Sleep(120,1) ;
  put '!EM_TO!' mail_id ;
  put '!EM_SUBJECT!' 'Test Plans have been created.' ;
  put 'The following test plans have been created with you as a tester.' ;
  put '<br>' ;
  end ;

id_link = '<a href="' ||left(strip(id)) || '">' || left(strip(id)) || '</a>' ;
put '<br>' ;
put id_link ;
put '<br>' ;

if last.mail_id then do ;
  put '<br>' ;
  put 'This is a system-generated message. Do not reply to this e-mail.' ;
  put '!EM_SEND!' ;
  put '!EM_NEWMSG!' ;
end ;
if EOF then put '!EM_ABORT!' ;
run ;

%mend send_email ;
%send_email ;

Jagadishkatam
Amethyst | Level 16

i am not sure about it though. But i believe if we do not have the licensed sas version, the email thing does not work. 

Thanks,
Jag
Kurt_Bremser
Super User

SAS uses the local mail agent to forward mail. You either have ) no working mail agent in the VM, or ) it does not have a valid mail relay configured and therefore the mails end up nowhere.

You can see the SAS configuration in your log when you do proc options; run; Look for options starting with EMAIL.

I don't know if the SAS UE VM can have access to the world outside of its host (your desktop PC). If yes, you might try to configure a valid mail relay (SMTP server) using these options.

suga badge.PNGThe SAS Users Group for Administrators (SUGA) is open to all SAS administrators and architects who install, update, manage or maintain a SAS deployment. 

Join SUGA 

CLI in SAS Viya

Learn how to install the SAS Viya CLI and a few commands you may find useful in this video by SAS’ Darrell Barton.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 1562 views
  • 1 like
  • 3 in conversation