I am using SAS EG8.3 and trying to send an email via SAS for the first time at this company. My code is as follows:
options emailsys=SMTP
emailport=25
emailid="myemail@mycompany.com";
options emailhost=
(
"smtp.office365.com"
port=25 STARTTLS
Auth=login
id="myID"
pw="mypw");
filename fileref email ("myemail@mycompany")
From="myemail@mycompany"
Subject="Test message"
type="text/html";
ods html body= fileref style=printer
text="Testing";
ods html close;
filename fileref clear;
The email log simply states:
ERROR: Email: The connection was refused.
I think I only just need to tweak a setting because if i switch this to emailsys=MAPI
the email will send but it prompts this message
Obviously I would like to email without the prompt. Any thoughts are appreciated.
What happens if you click "Allow"?
Talk to your IT folks about Outlook security settings to see if there is a way to avoid this popup.
The fact that it successfully sends your email indicates that your SAS program is using the right email settings. Most likely Outlook security settings need tweaking to stop the prompt which your IT security / email experts should be able to help with. Talking to your SAS administrator would be a good idea too.
what and where is that Outlook setting? If I can tell IT what I need changed, I have a much higher chance of getting it done.
Sending using MAPI will trigger your local Outlook client to send the message. The prompt you see is a security measure to prevent "rogue" processes from sending emails without your knowledge. (Imagine the spam bots that could exploit "quiet" automation of emails on your local PC...)
SMTP is the best practice for email automation. However, using Microsoft 365 and SMTP is tricky and might not be possible. See How to send email using SAS for general guidance about sending emails from SAS, including using cloud-based email.
These articles describe the requirements for getting SMTP working for Microsoft 365 from 3rd party apps, or alternatively using an API for the task:
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 16. 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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: