BookmarkSubscribeRSS Feed
Leo9
Quartz | Level 8

I am trying to send email from SAS and everything is working fine and as intended when I type my actual pwd in the SAS code using EMAILPW = option. Since I do not want to use my actual pwd in the program, I created an encoded pwd using PWENCODE procedure and stored it in the file with name 'pwfile'

 

1) Here is the first code to create the encoded pwd

 

filename pwfile 'Z:\Private\pwd\pwfile.txt';
proc pwencode in='pwd' out=pwfile;
run;

 

Now I am using code below to use this encoded pwd but I keep on getting login failure error.  Basically, SAS is not recognizing the encoded pwd correctly (as intended). 

 

Here is the second part for email. 

 

2) 

filename pwfile
'Z:\Private\pwd\pwfile.txt';
options symbolgen;
 
data _null_;
infile pwfile truncover;
input line :$64.;
call symputx('dbpass',line);
run;
 
options
  emailsys=smtp 
  emailauthprotocol= plain
  emailid = 'user@xyz.com'
  emailhost='smtp.office365.com'
  emailpw = "&dbpass"
  emailport=587
;
 
options emailhost=
 (
   'smtp.office365.com'  port=587
   STARTTLS  auth=login 
   id='user@xyz.com'
    pw="&dbpass" 
 )
;
 
/* Send email */
filename mymail email
    to="user@xyz.com"
attach = "Z:\Private\pwd\test.docx"
    subject="test";
 
data _null_;
    file mymail;
    put "this is test email";
run;
 
filename mymail clear;

 

Please provide any suggestions to correct this error. 

 

1 REPLY 1
Patrick
Opal | Level 21

For debugging purposes:
1: Run your program with code as simple as possible using your clear text password. Once that works:

2: Only replace the clear text password with the encoded version (not passed via a macro variable) and run again. Does this work or already fail?

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!

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