DATA Step, Macro, Functions and more

sending emails with attachment from sas

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 134
Accepted Solution

sending emails with attachment from sas

Hi,

 

we use ms outlook 2016 and can you please advise how to send an email to multiple recepients A) with an attachment file and B) short header and body of the email.

 

my attachment is saved on the C drive

 

Thanks


Accepted Solutions
Solution
‎05-23-2017 05:56 PM
Trusted Advisor
Posts: 1,137

Re: sending emails with attachment from sas

I believe the below article will be helpful for your requirement

 

http://www2.sas.com/proceedings/forum2008/038-2008.pdf

 

 

Thanks,
Jag

View solution in original post


All Replies
Solution
‎05-23-2017 05:56 PM
Trusted Advisor
Posts: 1,137

Re: sending emails with attachment from sas

I believe the below article will be helpful for your requirement

 

http://www2.sas.com/proceedings/forum2008/038-2008.pdf

 

 

Thanks,
Jag
Frequent Contributor
Posts: 134

Re: sending emails with attachment from sas

Posted in reply to Jagadishkatam

Hi,

 

I am using code that looks like this

 

%let label = &date.

 

data _null_;
file cmds;
put "[save.as(%bquote("X:\Weekly\File &label..xlsx"))]";
put '[CLOSE()]';
run;

 

FILENAME Mailbox EMAIL 'temp@microsoft.com'
Subject='Test Mail message' ATTACH='X:\Weekly\File May 2017.xls';
DATA _NULL_;
FILE Mailbox;
PUT "Hello";
PUT "Plesae find Report as an attachment";
PUT "Thank you";
RUN;

 

Question: as you can see, when I save my excel file it's using a variable/date as part of the file name but when I am referencing the attachment it's taking constant file name

 

how can I customize it to use variable file name when sending an email attachment, something like this

 

ATTACH='X:\Weekly\File &label..xlsx';

Trusted Advisor
Posts: 1,137

Re: sending emails with attachment from sas

when you mention macro variables you have to use double quotes

You can try below

ATTACH="X:\Weekly\File &label..xls";
Thanks,
Jag
Frequent Contributor
Posts: 134

Re: sending emails with attachment from sas

Posted in reply to Jagadishkatam

Thanks

Super User
Posts: 3,254

Re: sending emails with attachment from sas

Does SAS run on your PC? If so you will be able to pick up local drive attachments. You also need access to an email gateway - an SMTP one in your case.

 

If you are using SAS on a server it would need to be configured to use an SMTP gateway and your attachments would have to be accessible from your server.

Super User
Posts: 7,782

Re: sending emails with attachment from sas

And how are you using SAS?

- Locally with native Display Manager?

- Locally, but through Enterprise Guide?

- Remotely on a server? If yes, please specify:

  - the server's operating system

  - SAS Studio or Enterprise Guide?

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 1389 views
  • 0 likes
  • 4 in conversation