我无法将CSS样式应用于以html格式发送的电子邮件。如果将ODS输出保存到本地文件,则可以应用CSS样式。

有人可以帮助我如何在电子邮件步骤中传递CSS样式吗?

这是我使用的代码:

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;


提前致谢。

最佳答案

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();


最后通过创建自己的样式来完成要求。而不是使用CSSSTYLE。不确定如何使CSSSTYLE工作。我认为.msg和.html输出导致了此问题。

关于css - SAS结合使用CSSSTYLE和Email功能,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30768850/

10-09 14:03