Hello helpers,
I have tried to look for solutions but could not find any that could resolve the problem that I have.
The email sent automatically when production completed. Although the link shows correct file path when you hover around it, it will not direct to the correct path.
When copy the hyperlink from the email, it replaces "\" and space in the path, i.e. "file%3A%5C%5C".
Can anyone advise how to make the hyperlink work?
Test script:
%macro email_test_link(DS);
/*set the folder for hyperlink in the email*/
%let nobs=%eval(0) ;
proc sql noprint;
select nobs into :nobs
from dictionary.tables
where libname = 'WORK' and memname = %sysfunc(upcase("&ds"));
quit;
* Send email to developer for log check;
filename mymail email
to=(&email_to.)
TYPE='TEXT/HTML'
SUBJECT = "Production log check complete on &SYSDAY &SYSDATE9"
;
data _null_;
file mymail;
put '<html><head>';
put '<style type="text/css" MEDIA=screen><!--';
put 'body { color: #346170; font-family: Verdana; font-size: 12pt; }';
put '.errorMessage { color: Red; font-size: 16pt; }';
put '--></style></head><body>';
put "Hello -<br/> <br/> production is complete.";
put "<br/><br/>";
put "Check data outputs in the daily folder:";
put '<ul><li>';
put "<a href=&daily_data.>links</a>";
put "<br/></li></ul>";
put '<ul><li>';
put "Total records for &DS: &nobs <br><br>";
put "<br/></li></ul>";
%if &nobs = 0 %then %do;
put '<ul><li><span class="errorMessage">';
put 'Process may failed, check required!';
put "</span>";
put "<br/></li></ul>";
%end;
put '</body></html>';
put "<br><br>";
put "--------------------------------------------------------------------------------------------------<br>";
put "Job Started Execution at: &STARTTIME_Char and completed at: &CompletedTime_Char <br>";
put "SAS session started running at: &systime on &SYSDAY &SYSDATE9";
run;
%mend email_test_link;
%let daily_data = %sysfunc(URLENCODE(file:\\xx\HomeDir$\xx\Downloads\));
%let email_to=%str("xxx@xx.xx.xx" );
data test;
a="HHAAHA";
run;
%email_test_link(test);
Blind guess:
Add some quotes:
put "<a href='&daily_data.'>links</a>";
and change the \ to / when setting daily_data.
uses forward slashes, regardless of platform.
Change your PUT statement to this:
put '<a href="'"&daily_data."'">links</a>';
On which platform (operating system) do you read the mail, and with which application?
I played around with it (Apple mail client on a Mac). https: links are properly recognized and handed off to the browser, but the file: link needs to be right-clicked to call up the context menu containing "Open with...".
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.