Sending email message from SAS Enterprice Guide

toI have some data set, lets call it "FORMESSAGE"

enter image description here

I need to create a loop that will send text from data set "FORMESSAGE", variable MEssage to Email. For example text "Thank you" to mail "[email protected]", second letter text "Thank you very much" to [email protected] and etc (it can be mere than 100)

Here is what I have now:

filename outbox email
               to=(***)
               type='text/html'
               subject='MEssage'
               from='[email protected]';


      ods html body=outbox rs=none;

      proc print data=???;
      run;

      ods html close;

How to create loop for this case? Thank you very much!

Upvotes: 1

Views: 1516

Answers (1)

Chris J
Chris J

Reputation: 7769

You can use '!EM_...!' directives in a datastep :

filename em email type='text/html' from="[email protected]" ;
data _null_ ;
  file em ;
  set formassage ;
  put '!EM_NEWMSG!' ;
  put '!EM_TO!' email ;
  put massage ;
  put '!EM_SEND!' ;
  put '!EM_ABORT!' ;
run ;

https://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a002592795.htm

Embedding HTML :

filename em email type='text/html' from="[email protected]" ;
data _null_ ;
  file em ;
  set formassage ;
  put '!EM_NEWMSG!' ;
  put '!EM_TO!' email ;

  put "<html><body style='font-family:Arial;font-size:12px;'>" ;
  put "<div style='border:1px solid;width:100%;'>" ;

  put "To " customer_name ;
  put "<p>Please find attached your latest message." ;

  put "<p>" massage ;

  put "<p>Have a nice day!" ;

  put "</div>" ;
  put "</body></html>" ;

  put '!EM_SEND!' ;
  put '!EM_ABORT!' ;
run ;

Upvotes: 1

Related Questions