- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hey guys...
On googling, I found the following template to send the output in an email automatically,
%let subject = %str(Email configuration test);
%let fromEmail = '<Email Address>';
%let toEmail = '<Email Address>';
%let path = C:\documents and settings\&sysuserid.\my documents\test.htm;
FILENAME OUTPUT EMAIL
SUBJECT = "&subject."
FROM = &fromEmail.
TO = &toEmail.
CT ='text/html';
data _NULL_;
file output;
put "Working";
run;
I have a couple of SQL queries (Select queries) which I have written in PROC SQL in a SAS program, I want the output in HTML format to be sent in an email automatically. How would I change the above template or any other simpler method??
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
have a look at ATTACH E-mail option of the FILENAME statement in the doc at http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002058232.htm
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
filename eml email to='some@work.com';
proc printto print=eml;
proc sql;
select * from sashelp.class;
quit;
proc printto;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Missed that you wanted it in html format...
filename eml email to='someone@work.com' ct='text/html';
ods listing close;
ods html body=eml;
ods select sql_results;
ods noproctitle;
proc sql;
select * from sashelp.class;
quit;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I tried this but it looks like it delivered html code rather than output. What do you think?
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta name="Generator" content="SAS Software Version 9.3, see www.sas.com">
<meta http-equiv="Content-type" content="text/html; charset=windows-1252">
<title>SAS Output</title>
<style type="text/css">
<!--
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
This is something that i tried and got a proper result
ods _all_ close;
filename message email
from = "myid@mymail.com"
subject = "test"
ct="text/html";
ods html body = message style = minimal rs=none;
proc sql;
select * from sashelp.class;
run;
ods html close;
ods listing;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
GreggB,
This is normally the result of not setting the content type on the filename statement.
filename eml email to='someone@work.com' ct='text/html';
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks FriedEgg (Good name BTW:smileygrin:), it helped me a great deal, but its sending me the output (HTML format) embedded in the mail, not as an attachment. Any help on that would be great!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
If you are using the default MAPI email interface, you need to switch to using SMTP email in order to include HTML formatted email in the body of the message.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Oh, you want to send as attachment....
filename tmp temp;
%let afile=%sysfunc(pathname(tmp));
filename eml email
subject='attach something'
attach=("&afile" ct='text/html' name='procsql_results' ext='html');
ods html body=tmp;
proc sql;
select * from sashelp.class;
quit;
ods html close;
data _null_;
file eml;
put "It's done";
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you very much sir,
Is there possible to add a logic check only sent email if the sql return is not null?