DATA Step, Macro, Functions and more

Send Email with results attached as PDF

Reply
Contributor
Posts: 60

Send Email with results attached as PDF

Hello,

 

I have the below code which looks at exporting the datasets. However, I'd like the email to have the HTML results attached as a PDF instead - any ideas?

 

%let user = crf;
%let dataset=CIRC;
%let dataset1=/user/&user/CIRC.csv;

Data &dataset;
set CIRC;
run;
proc export data=&dataset
   outfile="&dataset1"
   dbms=csv
   replace; 
   run;

***update email recipients here***;
filename mymail email 
   To=("cameron.test@test.com" )
   subject="Circulation Report -  Prev 90 days"
   attach=("&dataset1");

data _null_;
   file mymail;
   put "Hello,";
   put " ";
   put "Please see the attached circulation file for campaigns sent in the last 90 days.";
   put " ";
    put "This report can be used as a retrospective sense check. ";
	put " ";
   put"Thanks,";
   put"CWR automated message";
 run; 
Super User
Posts: 10,520

Re: Send Email with results attached as PDF

Posted in reply to CamRutherford

I see nothing in your code that creates HTML output?

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Contributor
Posts: 60

Re: Send Email with results attached as PDF

Posted in reply to KurtBremser

Sorry, I posted just the email aspect of the code.

 

I create results (sas report) which is what I want attaching in the email.

 

Thanks

Super User
Posts: 10,520

Re: Send Email with results attached as PDF

Posted in reply to CamRutherford

To attach a file to an email, use the attach= option in the filename email statement.

 

To directly embed HTML output, use the content_type option:

 

filename out email 'receive@domain.com' content_type='HTML';

ods html body=out;

proc print data=sashelp.class;
run;

ods html close;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Super User
Super User
Posts: 9,789

Re: Send Email with results attached as PDF

Posted in reply to CamRutherford

Do be aware that email is a really poor medium for distributing data.  You could hit size or other restrictions, you also have multiple copies out there, no control, email is not secure etc.  Use a web portal, with access controls.

Ask a Question
Discussion stats
  • 4 replies
  • 100 views
  • 0 likes
  • 3 in conversation