Reputation: 409
I wrote some code which has to send one letter to one person with specified attachment. Here is the code:
%macro send;
%do i=1 %to &numPeople;
%let name = &&name&i;
%let to = &&UserMail&i;
options emailsys=smtp emailhost=smtp.mail.com emailport=25;
filename outbox email
to=('<[email protected]>' )
type='text/html'
subject="Data for &date_today &to "
from= ('< [email protected] >')
sender=('< [email protected] >')
importance='high'
attach=("/folder/statement&i..xlsx" ct='application/excel');
ods html body=outbox style=seaside;
data _null_;
file outbox;
PUT '<html><body>';
PUT ‘Dear coleagse <br><br>';
ods html close;
run;
%end;
%mend; %send;
The problem is that now this code sends one letter just attachment (without text), the second one to the same person as I need text + attachment. How to avoid first incorrect letter?
Upvotes: 1
Views: 633
Reputation: 71
There are two statements in your code instructing the email to 'send':
ods html close
statement will send the email. run;
) will send the email.If you remove both ODS statements (as you don't seem to be using the ODS for anything else), you should get just one email with the attachment and the text.
There's a good SAS Global Forum paper about sending emails from SAS here (PDF): Paper 038-2008 - Sending E-mail from the DATA step - Erik W. Tilanus, consultant, Driebergen, the Netherlands
Upvotes: 3