BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
FraudReporter
Calcite | Level 5

Hello,

After researching the topic, I have not found an answer. I know there are other threads on this topic, but none of the suggested solutions have worked for me, at least not when I run my code locally.

The problem:

Recently upgraded to Office 2010. The code that sends an email, and that worked previously does not function anymore. Instead, a know pop-up appears and reads:

"A program is trying to send an e-mail on your behalf. If this is unexpected, click Deny and verify your antivirus software is up-to-date."

If "Allow" is clicked, the email sits in the outbox until outlook is opened.

The code is run locally:

 

251 filename mymail email "first.lastname@mycompanyname.com" subject="test

252 message";

253 data _null_;

254 file mymail;

255 put 'hello there';

256 run;


I have already consulted the following:

http://support.sas.com/kb/5/335.html

http://support.sas.com/kb/19/767.html

and have attempted to alter the sasv9.cfg file as well as add the options to no avail:

 

249 options emailsys=smtp emailhost=mailer.mycompanyname.com emailport=25;

250

251 filename mymail email "first.lastname@mycompanyname.com" subject="test

252 message";

253 data _null_;

254 file mymail;

255 put 'hello there';

256 run;

NOTE: The file MYMAIL is:

E-Mail Access Device

ERROR: Email: The connection was refused.

NOTE: The SAS System stopped processing this step because of errors.

NOTE: DATA statement used (Total process time):

real time 0.17 seconds

cpu time 0.01 seconds

Now here's the twist. If I run that last piece of code through the unix server (i.e. through Rsubmit), it runs fine.

Any ideas as to how to get around this?

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
FraudReporter
Calcite | Level 5

@ data_null_ I performed some research online, but only found CDO references to VB script. I attempted to customize the code to "fill in the blank", but to be honest I am not sure I was able to get the proper parameters around user names/domain. I am not sure if those parameters I was inputing in the options or sasv9.cfg file were accurate, and I cannot get IT to clarify that for me.

I appreciate your input and will keep your suggestion handy as my current solution is a temporary patch.

Luckily, I still have access to the registry, and was able to perform the following action to get around the issue in a way.

 

At "HKEY_CURRENT_USER\Software\Policies\Microsoft\Office\14.0\outlook\security" create the following DWORDs with the value "2":

PromptSimpleMAPISend

PromptSimpleMAPINameResolve

PromptSimpleMAPIOpenMessage

This supresses the pop-up and the message is sent. However, the outlook window must be opened. If it's not open, the message sits in the outbox.

Of course, if anyone does not have access to the registry, they are out of luck. But this solves my issue for the time being.

Thanks to all who took the time to contribute, much appreciated.

View solution in original post

8 REPLIES 8
ballardw
Super User

You might check with your IT or whoever manages you email server. You might find that emailPort=25 is blocked.

or if they have installed some security software that needs to be informed that the SAS process is excluded from the blocking rules.

data_null__
Jade | Level 19

I think you are having the same problem I had, I had to switch to CDO mail.  I don't use and not longer have access to PC SAS so I can NOT test this to see if it still works but you might be able to get it working.  Change DOMAIN.COM to appropriate value for you. You can also BING/GOOGLE "CDO mail" and find info regarding the subject.  Your mileage may vary. :smileyplain:

data _null_;
  
length to script filevar command $256;
   to = catx(
'@',sysget('USERNAME'),'domain.com');

   script    = catx(
'\',pathname('WORK'),'email.vbs');
   filevar   = script;
  
/* write the script */
  
file dummy1 filevar=filevar;
   put 'Const sch="http://schemas.microsoft.com/cdo/configuration/"';
  
put 'Set myMail=CreateObject("CDO.Message")';
  
put 'With myMail';
   put +
3 '.Subject="Sending email with CDO"';
   put +
3 '.From="userid@domain.com"';
   put +
3 '.' To=:$quote128.;
   put +
3 '.TextBody="This is a message." & vblf & "This is line two"';
   put +
3 '.Configuration.Fields.Item (sch & "sendusing")=2';
   put +
3 '.Configuration.Fields.Item (sch & "smtpserver")="smtp.domain.com"';
   put +
3 '.Configuration.Fields.Item (sch & "smtpserverport")= 25';
   put +
3 '.Configuration.Fields.Update';
   put +
3 '.Send';
  
put 'End With';
  
put 'set myMail=nothing';

  
/* close the script file by opening another file, not used */
  
/* without this VBSCRIPT remains open and cannot be used below in the same data set */
   filevar = catx(
'\',pathname('WORK'),'DUMMY2.vbs');
   file dummy1 filevar=filevar;

  
/* look at the script, not necessary but may be useful */
  
infile dummy6 filevar=script end=eof;
   do _n_ = 1 by 1 while(not eof);
      input;
     
putlog 'NOTE: ' _n_ 3. +1 _infile_;
      end;

  
/* call the script */
   command = catx(
' ','cscript //nologo',quote(strip(script)));
   infile dummy7 pipe filevar=command end=eof;
   do while(not eof);
      input;
     
put _infile_;
     
end;
  
stop;
  
run;
FraudReporter
Calcite | Level 5

Thank you for this. I don't have access to the machine today, but will be able to test it next week. I will get back with the result.

H.

FraudReporter
Calcite | Level 5

Update, the code provided by data_null_ did not work unfortunately.

I will escalate within our help desk to see what can be done. Seems that in some cases adjusting the code will not be sufficient.

Thank you both for your help!

data_null__
Jade | Level 19

In way did the code "not work".  It has several "moving parts" so it is important to know what failed where.

Do you research CDO mail or just run the code I posted and stop there?

Kurt_Bremser
Super User

SAS either uses the local (on the machine that runs SAS) mail transfer agent or a connection to a mail (SMTP) server. It looks like your local MTA (outlook?) needs to be informed that SAS is allowed to send mails.

Or the SMTP server must be configured to accept the SAS machine as mail sending client.

FraudReporter
Calcite | Level 5

@ data_null_ I performed some research online, but only found CDO references to VB script. I attempted to customize the code to "fill in the blank", but to be honest I am not sure I was able to get the proper parameters around user names/domain. I am not sure if those parameters I was inputing in the options or sasv9.cfg file were accurate, and I cannot get IT to clarify that for me.

I appreciate your input and will keep your suggestion handy as my current solution is a temporary patch.

Luckily, I still have access to the registry, and was able to perform the following action to get around the issue in a way.

 

At "HKEY_CURRENT_USER\Software\Policies\Microsoft\Office\14.0\outlook\security" create the following DWORDs with the value "2":

PromptSimpleMAPISend

PromptSimpleMAPINameResolve

PromptSimpleMAPIOpenMessage

This supresses the pop-up and the message is sent. However, the outlook window must be opened. If it's not open, the message sits in the outbox.

Of course, if anyone does not have access to the registry, they are out of luck. But this solves my issue for the time being.

Thanks to all who took the time to contribute, much appreciated.

Harmoning
Fluorite | Level 6

You don't specify whether you are part of an Enterprise Outlook mail server or stand alone. I experienced your issue as part of the former, also using Office 2010. This affected automated (Windows task scheduler) jobs that ran prior to my 'in office' day, both SAS jobs and also Microsoft Access.

For the SAS jobs, we needed to change the email configuration options so that the SMTP server was sending the emails. SAS:Communications:E-mail options settings as follows:

Emailauthprotocol NONE

Emailfrom 0

Emailhost This would be your SMTP server DNS

Emailid Enter your email address

Emailport 25

Emailcutoffset

Emaildlg NATIVE

Emailsys SMTP

The Enterprise Outlook administrator may also need to specifically allow your workstation to use SMTP. The emails from SAS show your email in the FROM, but emails are not added to your SENT Items folder.

For Microsoft Access, we ended up installing a public domain security configuration tool called 'Click Yes' (http://www.contextmagic.com/?refid=cyproaboutdlg).

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
  • 8 replies
  • 12660 views
  • 6 likes
  • 5 in conversation