- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi again everyone.
I am trying to use an email task in EG 6.1 to send an email of an html file that was generated off of a SAS Report. My initial goal was to have that file embedded into the email. As of now, it will send it as an attachment. I found an article that I was trying to use to generate HTML emails from SAS but I am getting login failures. I am not sure why it won't work in a program task but if I put my SMTP settings into EG Tools->Options->Administration the email task sends fine. Current authentication is set up with my Windows account.
Here is the link to the article I am trying to make work: http://support.sas.com/resources/papers/proceedings10/060-2010.pdf
That may or may not be what I need to do but when I write a program I get the following error:
ERROR: Login failure
WARNING: Email: 503 5.3.3 AUTH not available
The code I am submitting:
options emailsys=SMTP;
options emailhost="smtp.domain.com";
filename myemail EMAIL
to="john.doe@somewhere.com"
to="msr.acquisitions@pncmortgage.com"
from="Test Person <test.person@myjob.com>"
subject="Daily Email"
content_type="text/html";
data _null_;
file myemail;
put "Testing Daily Email";
run;
My final result is to send and html image (or whatever format works) embedded in an email as part of a task in the process flow.
If there is more information I can provide to help with an answer please let me know.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Have you also set EMAILID and EMAILPW in your FILENAME statement? I can see not posting them but it is worth double checking.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Yes, I tried this statement and got the same error. I notieced that the emailsys option wasn't highlighted as a key word nor was it an option that intellensence offered when I was typing the code. I thought that was strange.
options emailsys=SMTP;
options emailhost="smtp.server.com";
options emailid="myid";
options emailpw="mypw";
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
This blog post about using Gmail to send e-mail from a SAS program might help. It shows an example of what you need when the e-mail server requires authentication and when it has a TLS/SSL component.
Excerpt:
options emailhost=
(
"smtp.gmail.com" port=465
SSL auth=plain
/* your Gmail address */
id="your_address@gmail.com"
/* optional: encode PW with PROC PWENCODE */
pw="your_password"
)
;
filename myemail EMAIL
to="lucky_recipient@gmail.com"
subject="Read SAS blogs";
data _null_;
file myemail;
put "Dear Friend,";
put "I recommend that you read http://blogs.sas.com ";
put "for lots of SAS news and tips.";
run;
filename myemail clear;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks @ChrisHemedinger. This got me a lot closer and then I got this message. We use Lotus notes. I don't get this error message when using the basic email task in Enterprise Guide. When I go to associate in default programs, I am not sure exactly what to associate it with. Any suggestions?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
But for automated e-mail (E-Mail as a Step, or using FILENAME EMAIL from a SAS program), you want to use SMTP. SMTP allows easier scripting of e-mail send actions without the local client. Usually, security settings prevent automated scripting of an e-mail client with a message like "A program is attempting to send e-mail on your behalf - do you want to allow it?" It requires a click to continue, which defeats the purpose of automating the e-mail. SMTP doesn't trigger that, since it goes directly to your company's e-mail-sending server.
You might need to do a little research in your organization to find out what the proper SMTP settings are, whether they require authentication and whether that auth is secured with SSL/TLS.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
In EG all I had to do was put in the SMTP server address and it works
fine. I didn't have to put any authentication info in. I have selected
the option for it to pull in my windows credentials. Maybe I need to
indicate that when scripting it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I think that's using NTLM, or single-signin for Windows. But when sending e-mail from your SAS session, your SAS server might not have that security context.
If your SAS session is on Windows, you can try this option:
No User/Password needed, and it should do the same as EG as long as you are connected to your SAS session with your Windows credentials. Well, maybe -- you might also need Trusted for Delegation to be enabled on that server machine. I don't know if e-mail is one of the operations that might trigger that check within the process.
If the SAS session is on Unix, you might need to support userid/password and additonal authentication options. You might need to ask a system admin for guidance about what you need. SMTP is a standard protocol that is used to script e-mail from all sorts of processes, so the information required isn't unique to SAS. A Unix admin should be able to tell you what's required.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you @ChrisHemedinger. I am going to give this a try today and see how it works. I appreciate it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@ChrisHemedinger I tried the following code and got the same pop up message about no email client being designated. My SAS EG session is on Windows. The SAS server (which I don't have access to) is Unix I believe but not sure.
So if I understand correctly, I would have to do something for Trusted Delegation differently when wriging a program to send this email versus what is done when EG sends it? I am just trying to make sense of why it will work through EG and not a script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
In your example, I can see that the program is running on your local machine (Local server), so that's going to (by default) try to send via your local e-mail client (your Lotus Notes).
Is that how you usually run your SAS programs? Local server always? If so, you'll still need to learn the proper settings for your SMTP server in your organization, and include those in the EMAIL* options that you have in your program.
I found a test service that lets you run through this mechanism: test.smtp.org. It won't actually send the e-mail to anyone you want to reach, but you can verify that your SAS program is working properly to send e-mail.
Once you have that, you can swap in the SMTP options for your organization and try the same.
options
emailsys=smtp emailhost=
(
"test.smtp.org" /* SMTP host name */
auth=plain /* Basic auth options */
id="user01"
pw="pass01"
)
;
filename myemail EMAIL
from="noreply@sas.com"
to="bit-bucket@test.smtp.org"
subject="Visit SAS Support Communities";
data _null_;
file myemail;
put "Dear Friend,";
put "I recommend that you visit http://communities.sas.com ";
put "for lots of great tips and connections!";
run;
filename myemail clear;
Successful log output:
NOTE: The file MYEMAIL is: E-Mail Access Device Message sent To: "bit-bucket@test.smtp.org" Cc: Bcc: Subject: Visit SAS Support Communities Attachments: NOTE: 3 records were written to the file MYEMAIL. The minimum record length was 12. The maximum record length was 54. NOTE: DATA statement used (Total process time): real time 5.74 seconds cpu time 0.01 seconds
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Yeah, looks like there may be an issue. I copied your script in and ran it and got the following log error.
1 The SAS System 13:05 Friday, January 22, 2016
1 ;*';*";*/;quit;run;
2 OPTIONS PAGENO=MIN;
3 %LET _CLIENTTASKLABEL='Program3';
4 %LET _CLIENTPROJECTPATH='L:\SAS Projects\Freddie Mac Dashboard Generation\Freddie Mac Dashboard Generation_prodde_v5.egp'
4 ! ;
5 %LET _CLIENTPROJECTNAME='Freddie Mac Dashboard Generation_prodde_v5.egp';
6 %LET _SASPROGRAMFILE=;
7
8 ODS _ALL_ CLOSE;
9 OPTIONS DEV=ACTIVEX;
10 FILENAME EGSR TEMP;
11 ODS tagsets.sasreport13(ID=EGSR) FILE=EGSR
12 STYLE=HtmlBlue
13 STYLESHEET=(URL="file:///C:/Program%20Files/SASHome94/SASEnterpriseGuide/6.1/Styles/HtmlBlue.css")
14 NOGTITLE
15 NOGFOOTNOTE
16 GPATH=&sasworklocation
17 ENCODING=UTF8
18 options(rolap="on")
19 ;
NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR
20
21 /*options EMAILAUTHPROTOCOL=login;
22
23
24 filename myemail EMAIL
25 to="me@work.com"
26 from="me@home.com"
27 subject="daily email"
28 content_type="text/html";
29
30 data _null_;
31 file myemail;
32 infile"C:\Users\me\Documents\file.htm";
33 input;
34 put _infile_;
35 run;*/
36
37 options
38 emailsys=smtp emailhost=
39 (
40 "test.smtp.org" /* SMTP host name */
41 auth=plain /* Basic auth options */
42 id="user01"
43 pw=XXXXXXXX
44 )
45 ;
46
47 filename myemail EMAIL
48 from="noreply@sas.com"
49 to="bit-bucket@test.smtp.org"
50 subject="Visit SAS Support Communities";
51
52 data _null_;
53 file myemail;
54 put "Dear Friend,";
55 put "I recommend that you visit http://communities.sas.com ";
56 put "for lots of great tips and connections!";
2 The SAS System 13:05 Friday, January 22, 2016
57 run;
NOTE: The file MYEMAIL 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 1.14 seconds
cpu time 0.00 seconds
58
59 filename myemail clear;
NOTE: Fileref MYEMAIL has been deassigned.
60
61 %LET _CLIENTTASKLABEL=;
62 %LET _CLIENTPROJECTPATH=;
63 %LET _CLIENTPROJECTNAME=;
64 %LET _SASPROGRAMFILE=;
65
66 ;*';*";*/;quit;run;
67 ODS _ALL_ CLOSE;
68
69
70 QUIT; RUN;
71
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
And to answer your questions, yes, EG is running on my local machine.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Ok, I just edited this to include only my company's SMTP server info without any login credentials and it work. I guess it decided to go ahead and use Windows Auth. So, that part is good. Now I will test embedding the image.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
To embed the html file in email message, try the code below:
filename myemail EMAIL
to="john.doe@somewhere.com"
to="msr.acquisitions@pncmortgage.com"
from="Test Person <test.person@myjob.com>"
subject="Daily Email"
content_type="text/html";
data _null_;
file myemail;
infile "<file_path>/<filename>.htm";
input;
put _infile_;
run;