BookmarkSubscribeRSS Feed
yus03590
Calcite | Level 5

Hi!  I'm trying to add logging function to an automated report that specifies whether an email was sent successfully.  I'm currently using the filename...email method as shown below and the code works. 

filename outbox email
			%if &debug_flag = 0 %then %do;
				to=&to_emails
			%end;
			%else %do;
				to='Smith, John <someemail@myuniversity.edu>' /* debug email list */
			%end;
			from='Smith, John <someemail@myuniversity.edu>' 
			bcc=&bcclist
			sender='Smith, John <someemail@myuniversity.edu>' 
			reply='Smith, John <someemail@myuniversity.edu>' 
			content_type="text/html"
		%if &wrapup_exit_status = 0 %then %do;
			attach=("&rptpath/&rptfn"
					ENCODING='utf-8'
					CONTENT_TYPE='application/pdf'
					EXTENSION='pdf'
			)
			subject="Entrance Reports &deptnm MTC &rptwk"
		;
		ods html5 style=pearl body=outbox /* Mail it! */;
		proc odstext;
			p 'Hello, ';
			p 'The highlight table at the front includes anyone that responded with information that could be important to know. The following items cause an employee to appear:';
			list
				item 'Marked any need in the special needs section';
				item 'Have been a service member less than 3 years';
				item 'Individuals older than 27';
				item 'Indicated both struggling in training';
				item 'Indicated both not having attended high school';
			end;
		%end;
		%else %do;
subject="Entrance Reports &deptnm &rptwk"
		;
		ods html5 style=pearl body=outbox /* Mail it! */;
		proc odstext;
			p 'Hello, ';
			p 'There are no individuals which have been flagged with special needs this week';
		%end;
			p 'Let me know if you have any questions';
		run;

		ods html5 close;

Usually for procedures I can simply check &syserr.  However from what I gather when email information is sent to the email server the server simply accepts the request and doesn't send status codes (like if the email had an invalid address).  Is there a way to work around this?  I just need to know whether an email sent successfully, not specific details.

 

Thanks!

1 REPLY 1
Patrick
Opal | Level 21

@yus03590

I believe you're dealing with an asynchronous process and the only thing you can get is the response that your request for sending an email was successful.

 

You would need to find a way to query the email server directly.

 

You can find quite a few non-SAS related discussions on the Internet around this topic. If any of these can give you a solution approach will depend on your level of access to the email server.

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
  • 263 views
  • 0 likes
  • 2 in conversation