below code i am trying to execute but im not getting mails as mentioned in this code ...any one can tell whts wrong on this code,,
%MACRO MAIL;
filename myfile "D:/LOG/&sysdate _ &systime _log.txt" ;
proc printto log=myfile;
run;
%if &SYSerr =0 %then %do;
FILENAME outmail EMAIL
SUBJECT="generated succesfully"
FROM="....." to="..........";
FILE outmail;
PUT "Dear Sir/Madam";
PUT " ";
PUT "Report generated succesfully";
RUN;
%end;
%ELSE %IF &SYSerr > 1 %THEN %DO;
/*this is mail body to send mails */
FILENAME outmail EMAIL
SUBJECT="report generated"
FROM="................" to="................."
attach="D:/LOG/&sysdate _ &systime _log.txt";
FILE outmail;
PUT "Dear Sir/Madam";
PUT " ";
PUT "ERROR OCCURED";
RUN;
%END;
%MEND;
%MAIL;
Thanks in advance
Tell us more.
You posted to the EGuide forum. Are you doing this through eguide?
Is your SAS server local?
The e-mail task in EGuide uses the client; does that work?
Are you getting any error or other messages in the log?
Do you have e-mail access from the server at all?
Can you send email without the macro part?
What are your mail settings (from PROC OPTIONS)?
There are so many moving parts with e-mail that your code might be good, but the process breaks elsewhere.
Doc Muhlbaier
Duke
first thanks for ur replay...Duke
I am using this code in SAS EG with SAS MAIN Server and ,no i am unable to see log because of printto procedure
Yes i have mail acess.with out macro's i am able to send mails
i'm not using any mail options
Thank You,
Ramesh
I believe one possible cause is that &systime will resolve to something with a column ':' in it.
filename myfile "D:/LOG/&sysdate _ &systime _log.txt" ;
A column is not a valid character for names in Windows so things will go wrong there already.
I would suggest that as a first step you put your "filename ..., proc printto" in comment and use some other file for attachement. Then run the code and let us know if this works - or what the log tells you.
Hi,
Please check something...
You seem to be on a BI server platform.....
so instead of defining a path to windows try changing ur filename path to a path on your server
also i think the proc printto will create a .log file and not a .txt so you might have to change your extension too....
I cannot test any of this as of now ..... so would hope it helps..
%MACRO MAIL;
filename myfile "/myserverpath/LOG/&sysdate _ &systime _log.log" ;
proc printto log=myfile;
run;
%if &SYSerr =0 %then %do;
FILENAME outmail EMAIL
SUBJECT="generated succesfully"
FROM="....." to="..........";
data _null_;
FILE outmail;
PUT "Dear Sir/Madam";
PUT " ";
PUT "Report generated succesfully";
RUN;
%end;
%ELSE %IF &SYSerr > 1 %THEN %DO;
/*this is mail body to send mails */
FILENAME outmail EMAIL
SUBJECT="report generated"
FROM="................" to="................."
attach=/myserverpath/LOG/&sysdate _ &systime _log.log;
data _null_;
FILE outmail;
PUT "Dear Sir/Madam";
PUT " ";
PUT "ERROR OCCURED";
RUN;
%END;
%MEND;
%MAIL;
I think the first thing to do is make sure the log is being generated. Then review the log to see if that points to your problem. Also, try removing the macro if logic and just generate an e-mail when the macro is run.
If you get all the way to generating an e-mail...then the problem could be diagnosed from your code.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.