SAS using CSSSTYLE and Email functionality together

1.4k views Asked by At

I am not able to apply my CSS styles to an email which I am sending it as a html format. If I save the ODS output to a local file, I am able to apply my CSS styles.

Could someone help me on how to pass the CSS styles in an email step?

Here is the code I used:

FILENAME SETMAIL EMAIL TO=("[email protected]")
         SUBJECT = "This is a test email with applied CSS HTML styles to email " 
         TYPE="text/html" 
         CONTENT_TYPE='text/html' ;
         ODS HTML BODY=setmail
         CSSSTYLE="D:\\myStyles_EMAIL.css";

TITLE "Be focused !! ";      
PROC PRINT DATA=DODEV.RECENT_HIGH_VOL_ORDERS noobs label;
RUN;
ODS HTML CLOSE;
ODS LISTING;

Thanks in advance.

2

There are 2 answers

9
Robert Penridge On

Try using ODS HTML3. This embeds the style information directly into the HTML elements so that no CSS is used to render (all the style information is stated repeatedly and explicitly within each HTML tag).

This ODS destination is great for backwards compatibility. And seeing as the HTML rendering engine used by Outlook is actually the MS Word Engine, a lot of backwards compatability is required.

Here's the ODS HTML3 doc link: http://support.sas.com/documentation/cdl/en/odsug/61723/HTML/default/viewer.htm#a002596390.ht

Not all HTML formatting is supported by a lot of email clients though. Here's some useful links to give you a good background of what can and can't be done, and what is and isn't supported:

http://24ways.org/2009/rock-solid-html-emails

http://www.emailology.org

http://www.campaignmonitor.com/css/

HTML email align text

0
Naga Vemprala On
proc template; 
    define style styles.MyMail;
    parent= styles.journal; 
    style body /
        fontfamily="Arial, Helvetica, Sans-serif"
        fontsize= 2
        fontweight=medium
        fontwidth=normal
        color=blg
        backgroundcolor=white
        marginleft=8pt
        marginright=8pt;
    style header /
        fontfamily="Arial, Helvetica, Sans-serif"
        fontsize= 4
        fontweight=bold
        fontstyle=roman
        bordercolor=black
        textalign=center
        backgroundcolor=CX00365B
        color=white;
    style Data / 
        fontfamily="Arial, Helvetica, Sans-serif"
        fontweight=medium
        fontsize=2
        fontstyle=roman
        color=black
        backgroundcolor=white;
    style SystemTitle / 
        fontfamily="Arial, Helvetica, Sans-serif"
        fontweight=bold
        fontsize=6
        fontstyle=roman
        textalign=left
        color=white
        backgroundcolor=CX00365B;
    style SystemTitle2 / 
        fontfamily="Arial, Helvetica, Sans-serif"
        fontweight=bold
        fontsize=4
        fontstyle=roman
        textalign=left
        color=white
        backgroundcolor=CX00365B;
    style SystemTitle3 / 
        fontfamily="Arial, Helvetica, Sans-serif"
        fontweight=medium
        fontsize=2
        fontstyle=roman
        textalign=left
        color=black
        backgroundcolor=white;
     end;
run;

%MACRO SEND_EMAIL_NOTIFICATION(); 

%IF &NUM_CONDS > 0 %THEN

     %DO;       
           FILENAME SETMAIL EMAIL TO=( "[email protected]")
                SUBJECT = "Alert: XXXXXXXX" 
                TYPE="text/html" 
           CONTENT_TYPE='text/html';
           ODS html3  BODY=SETMAIL 
           STYLE=MYMAIL;

           TITLE "Some title 1 ";
           TITLE2 As of &RUN_TIME;
           TITLE3 A total of &NUM_XYZz Some titles, since the last report;
           TITLE4 " " ;

           PROC PRINT DATA=DEV.RECENT_DS noobs label;
           RUN;
           ODS HTML3 CLOSE;
           ODS LISTING;
     %END;
%MEND;

%SEND_EMAIL_NOTIFICATION();

Finally completed the requirement by creating my own style. Rather than using the CSSSTYLE. Not sure how to make the CSSSTYLE work. I think the .msg and .html outputs are causing the issue.