options emailsys = smtp
emailauthprotocol= login
EMAILACKWAIT=30
emailid = 'runnerupwang@outlook.com'
emailpw = 'XXXXXX'
emailhost = 'smtp.live.com'
emailport = 25 ;
filename f_email email
to = '1055103120@qq.com'
from = 'runnerupwang@outlook.com'
subject = 'Automatic Email Sending Test'
;
data _null_;
file f_email;
put 'This is a test email with an RTF attachment via SAS programming.';
run;
I'm trying to send the email in the SAS9.4 with outlook mail, but failed, and I got an error message below, it seems that I should specify SSL, but I don't know how. Thanks for your info
ERROR: Login Failed
ERROR: Email: 530 5.7.0 Must issue a STARTTLS command first
PS: This code works if I changed the sender to 163 mail, and emaihost to smtp.163.com
This:
http://blogs.sas.com/content/sasdummy/2013/07/31/gmail-from-sas-program/
may point you in the right direction.
Thanks for your support. The final solution for sending the email with Outlook Account is similar to your sample code. I have setup the emailhost option in the second part option, I wonder why I have to setup the first part system options.
/*First part Option Setup*/
options emailsys = smtp
emailauthprotocol= login
EMAILACKWAIT=30
emailid = '******@outlook.com'
emailpw = 'XXXXXX'
emailhost = 'smtp-mail.outlook.com'
emailport = 25 ;
/*Second part Option Setup*/
options emailhost=
(
'smtp-mail.outlook.com' port=587
STARTTLS auth=login
id='******@outlook.com'
/* optional: encode PW with PROC PWENCODE */
pw='XXXXXX'
)
;
filename f_email email
to = ('OutMail_Address1' 'OutMail_Address2')
subject = 'Automatic Email Sending Test'
attach = 'C:\Users\Think\Desktop\test.rtf'
;
data _null_;
file f_email;
put 'This is a test email with an RTF attachment via SAS programming.';
run;
filename f_email clear;
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!
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.