BookmarkSubscribeRSS Feed
yashpande
Obsidian | Level 7

Hi All,

My question is related to send emails to users. I have a data set user_details which has variable user_name and another dataset file_details which has list of big files (over 10gb )against those users. I need to send emails to all of them asking to delete unnecessary files.

Sample user_details table :

User_name

L01234

M09677

Sample file_details:

User_name File_name Size

L01234 c:\test1.txt 12

L01234 c:\test2.txt 11

M09677 d:\sample1.txt 34

M09677 d:\ sample2.txt 17

So I need to send emails to users L01234 and M09677.  Email should be something like

Hi L01234,

Please delete unnecessary files.

You may look at following files:

C:\test1.txt

C:\test2.txt

Similar mail should be sent to user M09677

Any ideas on how to accomplish this ?

1 REPLY 1
mnjtrana
Pyrite | Level 9

Hi,

 

You can use the below sample code to send emails to the users, first we set your input dataset, lets call it -' have', the code will create a script in temp loation named(email_snd), which will be called using %inc and email will be sent based on data provided in the have data-set.

 

filename email_snd temp;

data _NULL_;
set have; /*put you input dataset name here*/

length 
rec1 $50. rec2 $50. rec3 $30. rec4 $30. rec5 $30. rec6 $30. rec7 $30.;

rec1 = %nrstr("filename mymail email '#email_id#@site.com' subject='Delete Big Files';");
rec1 = tranwrd(rec1, '#email_id#', User_name);
rec2 = %nrstr("data _null_;");
rec3 = %nrstr("file mymail;");
rec4 = %nrstr("put 'Hi #usr_id#';");
rec4 = tranwrd(rec4, '#usr_id#',User_name);
rec5 = %nrstr("put 'Please delete unnecessary files.';");
rec6 = %nrstr("put 'You may look at following files:';");
rec7 = %nrstr("put '#file_name#' ;");
rec7= tranwrd(rec7, '#file_name#', File_name);

file email_snd;
put 
rec1 /
rec2 /
rec3 /
rec4 /
rec5 /
rec6 /
rec7;

run;

%inc email_snd;
run;

 


Cheers from India!

Manjeet

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 1 reply
  • 625 views
  • 0 likes
  • 2 in conversation