01-15-2016 11:06 AM
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="email@example.com" to="firstname.lastname@example.org" from="Test Person <email@example.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.
01-15-2016 12:23 PM
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.
01-15-2016 12:31 PM
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.
options emailhost= ( "smtp.gmail.com" port=465 SSL auth=plain /* your Gmail address */ id="firstname.lastname@example.org" /* optional: encode PW with PROC PWENCODE */ pw="your_password" ) ; filename myemail EMAIL to="email@example.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;
01-15-2016 05:54 PM
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?
01-17-2016 11:09 AM
01-19-2016 12:10 PM - last edited on 01-20-2016 07:38 AM by ChrisHemedinger
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?
01-20-2016 07:47 AM
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.
01-22-2016 10:45 AM
@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.
01-22-2016 11:19 AM - edited 01-22-2016 11:23 AM
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="firstname.lastname@example.org" to="email@example.com" 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: "firstname.lastname@example.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
01-22-2016 02:08 PM
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
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=;
8 ODS _ALL_ CLOSE;
9 OPTIONS DEV=ACTIVEX;
10 FILENAME EGSR TEMP;
11 ODS tagsets.sasreport13(ID=EGSR) FILE=EGSR
NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR
21 /*options EMAILAUTHPROTOCOL=login;
24 filename myemail EMAIL
27 subject="daily email"
30 data _null_;
31 file myemail;
34 put _infile_;
38 emailsys=smtp emailhost=
40 "test.smtp.org" /* SMTP host name */
41 auth=plain /* Basic auth options */
47 filename myemail EMAIL
50 subject="Visit SAS Support Communities";
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
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
59 filename myemail clear;
NOTE: Fileref MYEMAIL has been deassigned.
61 %LET _CLIENTTASKLABEL=;
62 %LET _CLIENTPROJECTPATH=;
63 %LET _CLIENTPROJECTNAME=;
64 %LET _SASPROGRAMFILE=;
67 ODS _ALL_ CLOSE;
70 QUIT; RUN;
01-22-2016 02:14 PM
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.
01-22-2016 04:35 AM
To embed the html file in email message, try the code below:
filename myemail EMAIL to="email@example.com" to="firstname.lastname@example.org" from="Test Person <email@example.com>" subject="Daily Email" content_type="text/html";