BookmarkSubscribeRSS Feed
ColeG
Obsidian | Level 7

My company has recently switched to SAS Enterprise Guide and I am updating all my codes. One thing that I need to do is send out large batches of emails with attachments.

 

I know that to include .xlsx files you need to add the line

content_type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" lrecl=32000

 to your attach= statement.

 

My question is, how do you send multiple attachments, of the same or different types, in one email? I have verified that each attachment works individually (I have six total attachments to send), but only the last one attached can be opened.

 

Thanks!

 

%macro emaildata (to_address, attachments);
 Filename output email;
 data _null_;
	file output
	to = (&to_address.)
	subject = "subject"
	attach = (&attachments. content_type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" lrecl=32000);

 put "text."; 

run;
%mend emaildata;

%emaildata (recipient, "&attachment1." "&attachment2." "&attachment3." "&attachment4." "&attachment5." "&attachment6.");
1 REPLY 1
tomrvincent
Rhodochrosite | Level 12

This works for me:

 

	/* email files */
	filename outbox email 'ron@acme.com';

	data _null_;
		file outbox

		/* Overrides value in filename statement */
		to=("&EMAILADDRESS" )
		subject="reports "
		
		attach=
		(
		"&outputpath./&pdbym._results.csv"
		"&outputpath./&pdbym._detail.csv"
		"&outputpath./177_&pdbmy.-&pdemy..html"
		"&outputpath./177_&pdbmy.-&pdemy..pdf"
		"&outputpath./177_&pdbmy.-&pdemy..xlsx"	content_type="application/xlsx" lrecl=32000 	
		"&outputpath./Claims_&pdbmy.-&pdemy..pdf" 
		"&outputpath./Claims_&pdbmy.-&pdemy..html" 
		"&outputpath./Claims_&pdbmy.-&pdemy..rtf"
		"&outputpath./Lines_&pdbmy.-&pdemy..pdf" 
		"&outputpath./Lines_&pdbmy.-&pdemy..html" 
		"&outputpath./Lines_&pdbmy.-&pdemy..rtf"
		"&outputpath./claims30.xlsx" content_type="application/xlsx" lrecl=32000 
		"&outputpath./interest.xlsx" content_type="application/xlsx" lrecl=32000
		"&outputpath./badclaims1.xlsx" content_type="application/xlsx" lrecl=32000
		"&outputpath./badclaims2.xlsx" content_type="application/xlsx" lrecl=32000
		"&outputpath./Detail_File.xlsx" content_type="application/xlsx" lrecl=32000
		)
		;
		
		put "Enjoy these exciting  reports .";
	run;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 1 reply
  • 3911 views
  • 1 like
  • 2 in conversation