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

Greetings,

 

1. I would like to send email using SAS, and would like to include a table from SAS embedded inside the email itself (not with attached file).

2. What would be the best way to address this issue? Should I use ODS for this or some other process?

 

Thanks!

 

1 ACCEPTED SOLUTION

Accepted Solutions
mstacey_foresters_com
Fluorite | Level 6

This will Produce a table inside the email.

 

options emailsys=smtp;

options emailauthprotocol=none;

options emailhost="xx.xx.xx";

options emailport=25;

options emailpw = "xxxxxx";

 

 

filename temp email

to = ( "xxxxx@xxxx.com" )

cc = ("xxxxx@xxxx.com" )

subject="Email With Table"

type="text/html"

from = "xxxxx@xxxx.com"

reply = "xxxxx@xxxx.com" ;

 

 

 

 

 

ODS html body=temp style = noline;

ods html text = "Good Morning,";

ods html text = "";

 

PROC REPORT DATA=X nowd HEADLINE HEADSKIP

 

style (report) = {background = white

font_face = "Verdana" font_size = 7pt just=left }

style (column) = {background = white CELLHEIGHT = 2.5%

font_face = "Verdana" font_size = 7pt just=left}

style (header) = {foreground = cx5e2750 font_face="Verdana"

font_size = 8pt just=left

background = white} ;

columns

DATE

TIME

FN

C;

DEFINE DATE / 'Date';

define TIME / 'Time';

define FN / "File Name";

define C / "Run Number";

 

run;

 

 

 

 

 

ods html text = "Have a Great Day.";

ods _all_ close;

 

Cheers.

View solution in original post

23 REPLIES 23
mstacey_foresters_com
Fluorite | Level 6

This will Produce a table inside the email.

 

options emailsys=smtp;

options emailauthprotocol=none;

options emailhost="xx.xx.xx";

options emailport=25;

options emailpw = "xxxxxx";

 

 

filename temp email

to = ( "xxxxx@xxxx.com" )

cc = ("xxxxx@xxxx.com" )

subject="Email With Table"

type="text/html"

from = "xxxxx@xxxx.com"

reply = "xxxxx@xxxx.com" ;

 

 

 

 

 

ODS html body=temp style = noline;

ods html text = "Good Morning,";

ods html text = "";

 

PROC REPORT DATA=X nowd HEADLINE HEADSKIP

 

style (report) = {background = white

font_face = "Verdana" font_size = 7pt just=left }

style (column) = {background = white CELLHEIGHT = 2.5%

font_face = "Verdana" font_size = 7pt just=left}

style (header) = {foreground = cx5e2750 font_face="Verdana"

font_size = 8pt just=left

background = white} ;

columns

DATE

TIME

FN

C;

DEFINE DATE / 'Date';

define TIME / 'Time';

define FN / "File Name";

define C / "Run Number";

 

run;

 

 

 

 

 

ods html text = "Have a Great Day.";

ods _all_ close;

 

Cheers.

DanielDor
Obsidian | Level 7

Thanks! Work like a charm 🙂

Lenvdb
Quartz | Level 8
Can this work if I want to embed 3 small datasets as reports in a single email as html? How would I do this? What would the structure be?
pratixitvajpai
Calcite | Level 5

I am using the same code but for, "options emailhost = "XX.XX.XX" ;    ". I am getting error. I am using my company's host email yet it says, "Email host couldn't be found" 

what could be wrong, someone please help me

 

Thanks

Cynthia_sas
SAS Super FREQ
Hi:
It would have been better for you to create a new posting and then refer to this older post. You added a new question to a 3 year old posting.
However, in order to use any email features of SAS, you MUST work with your SAS Administrator in order to make sure that the correct system options relating to email have been set. If the options are not set when SAS starts up, you will NOT be able to do any emailing from a program.
So the appropriate place to start is with your SAS Administrator to find out whether you're allowed to send email, and if so, the name of the host to use and then verify that the necessary system options have been set.
Cynthia
vikpik
Calcite | Level 5

Use following. Keep adding Proc Report for all additional dataset you want to send in email:-

 

 

filename temp email

TO=("email@domainname.com")

subject="POC starting Queue"

type="text/html"

from = "youremail@domainname.com";

ODS html body=temp style = analysis;

ods html text = "Hi All";

ods html text = " ";

ods html text = "Following Accounts are pending POC :-";

 

 

 

PROC Report data=RVPOCFINAL nowd HEADLINE HEADSKIP

style (report) = {background = white

font_face = "Verdana" font_size = 7pt just=left }

style (column) = {background = white CELLHEIGHT = 2.5%

font_face = "Verdana" font_size = 7pt just=left}

style (header) = {foreground = cx5e2750 font_face="Verdana"

font_size = 8pt just=left

 

background = white} ;

columns

column_name1

column_name2

column_namexx

;

run;

 

SASdevAnneMarie
Barite | Level 11
Hello,
When I run this code I have an ERROR : ERROR: Email host xx.xx.xx not found.
Could you help me please with this option ?

Thank you !
Cynthia_sas
SAS Super FREQ
Hi:
If the email host cannot be found, then that means you need to find out from your mail administrator what the correct host name is. You'll also need to check with your SAS Administrator to make sure that the email-related system options refer to the correct settings. If you need more help, your best resource is SAS Tech Support.
Cynthia
SASdevAnneMarie
Barite | Level 11
Than you, Cynthia !

Where can I found the email host? Is it in my log ?
Cynthia_sas
SAS Super FREQ
Hi:
That information needs to come from your email administrator and your SAS administrator needs to know the value for EMAILHOST so they can use it in the configuration files for SAS.
Cynthia
SASdevAnneMarie
Barite | Level 11
Thank you, Cynthia !
Without knowing the EMAILHOST I can’t send this kind of email, or there are some other options please ?
Cynthia_sas
SAS Super FREQ
Hi:
Please take a look at this user group paper: https://support.sas.com/resources/papers/proceedings11/101-2011.pdf -- in it you'll see that the author had to work with the team at his company to get things working. You need to work with someone AT YOUR COMPANY to get this working. There's not any way for someone on the Forum to know what your settings at your company need to be. And no one on the Forum has any permissions to alter the configuration files needed by SAS at your company.
Cynthia
SASdevAnneMarie
Barite | Level 11
Thank you very much, Cynthia!

That works!
vikpik
Calcite | Level 5

i have a different issue related to this. It works fine as long as I'm running the code manually. However When I'm running this through cron job, it is not capturing the columns. Anyone has any idea to solve for this?

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 23 replies
  • 30100 views
  • 8 likes
  • 9 in conversation