BookmarkSubscribeRSS Feed
RameshReddy
Calcite | Level 5

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

5 REPLIES 5
Doc_Duke
Rhodochrosite | Level 12

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

RameshReddy
Calcite | Level 5

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

Patrick
Opal | Level 21

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.

NN
Quartz | Level 8 NN
Quartz | Level 8

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;

Jay_OAG
Calcite | Level 5

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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 1098 views
  • 0 likes
  • 5 in conversation