I can easily generate HTML based emails with logos and attachments. Yesterday I was requested to capture a copy of selected emails (for audit purposes) and one suggestion was to get a new email account to log and save the emails to a folder. Sounds good but not sure if or how long it might take to get a new email account and to then be able to redirect the email to a folder and give it an unique name.
While I know I can use multiple filenames to write out content, I am afraid the use of all those email statements that start with EM_ are too specific to make this work as expected. I mean think about how to store say an Excel file if it is not using the email engine.
It may vary a bit on the code but could you just wrap the code in ODS EXCEL?
You would be way better off creating a dedicated email account to store copies of the emails sent. That way you can be sure that it only contains that were actually sent. If you try doing it all from SAS then it's quite possible that it could create emails that were never sent. Also you are avoiding a lot extra coding.
@Reeza - I was thinking more along the lines that an email account "Sent" folder is the most accurate record of what emails were sent so this would be good for audit purposes. Writing out individual emails is as easy as opening them and doing a "File Save As" (not something you would manually do for all emails obviously) but I guess it all depends on the use case details of the OP.
In the SAS program that sends the email, you could BCC the email account for archiving emails. And then I would let that account manage the process of filing the emails into a folder through Outlook automation or VBA or whatever.
I generally BCC myself on automated emails I send from SAS jobs, then have an outlook rule that files them based on the subject or sender or whatever.
Thanks Quentin, I like the idea overall. Our SAS server is on Linux - is there a way to maybe create a new email account for this purpose and instead of using MS Outlook, have the emails go to some Outlook equivalent email on the Linux box? I do not think I can set an Outlook rule that will route the email back to the Linux box but then again, I have not tried it either.
Point is, I guess there is no way to have another FILENAME / FILE combo to write out the generated email within SAS. I know this is an odd request but I can see the value in storing selecting emails to ensure everyone got it and to historically reference them for audit purposes. This is a new requirement and I of course would like to automate the entire task...
Talk to your IT email experts. In my experience they are very helpful when creating non-personal email accounts for specific business purposes. One common use is to advise SAS users when scheduled jobs have failed.
Why do you need the emails stored on your SAS server? As long as they are accessible by users they can be stored anywhere and its a lot easier to use your existing email systems than to set up a new one.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.