A program is trying to send an email on your behalf

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 9
Accepted Solution

A program is trying to send an email on your behalf

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!


Accepted Solutions
Solution
‎01-29-2015 09:58 AM
Occasional Contributor
Posts: 9

Re: A program is trying to send an email on your behalf

@ 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


All Replies
Grand Advisor
Posts: 10,211

Re: A program is trying to send an email on your behalf

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.

Respected Advisor
Posts: 3,775

Re: A program is trying to send an email on your behalf

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;
Occasional Contributor
Posts: 9

Re: A program is trying to send an email on your behalf

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.

Occasional Contributor
Posts: 9

Re: A program is trying to send an email on your behalf

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!

Respected Advisor
Posts: 3,775

Re: A program is trying to send an email on your behalf

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?

Esteemed Advisor
Posts: 6,669

Re: A program is trying to send an email on your behalf

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.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Solution
‎01-29-2015 09:58 AM
Occasional Contributor
Posts: 9

Re: A program is trying to send an email on your behalf

@ 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.

Occasional Contributor
Posts: 5

Re: A program is trying to send an email on your behalf

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).

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 8 replies
  • 3975 views
  • 6 likes
  • 5 in conversation