BookmarkSubscribeRSS Feed
Florent
Quartz | Level 8

Hi all,

Would anyone of you know whether this is possible to generate an email (to:, cc:, header, content and attachment) but without sending it directly (under windows) ?

The purpose would be to save this email in a directory so that the Business might send it after validation of the attachment.

I've checked multiple white papers on the internet but unfortunately without finding anything interesting.

Thanks upfront for the help.

Regards,

Florent

8 REPLIES 8
Doc_Duke
Rhodochrosite | Level 12

Florent,

I'm not sure that you can do that as an e-mail is not a file.

My approach has been to send the e-mail from SAS to an "intermediary" e-mail address where it is checked and forwarded it as appropriate.  It adds a little garbage to the header, but accomplishes the goal.

Doc Muhlbaier

Duke

SASJedi
SAS Super FREQ

You can create an email without immediately sending it - details in the YouTube video SAS Programming Tip: Write an Email in SAS and Delay Sending  You'd have to somehow automate the "Save as Draft" in Outlook, though.

Regards,

SASJedi

Check out my Jedi SAS Tricks for SAS Users
Florent
Quartz | Level 8

All,

I did accomplish the goal of my request by:

  • generating a VB script with SAS
  • having the VB script executed via a DOS command launched from SAS

For those who are interested, I could share a sample of the SAS program that I have created.

Regards,

Florent

P.S: What is the trick to use in order to copy/paste a SAS program into a post ? Each time I do it, I loose a lot of code...

Doc_Duke
Rhodochrosite | Level 12

To your PS:, just click "use advanced editor" in the top right corner of the message screen.

Florent
Quartz | Level 8

I've tried but it still looses some lines of my code... It also breaks some lines of code into multiple lines in my post  :smileyconfused:

Isn't it possible to use an html tag in order to quote the code ? I saw a lot of correctly formatted code on the old SAS discussion forum.

Thanks!

data_null__
Jade | Level 19

Florent wrote:

I've tried but it still looses some lines of my code... It also breaks some lines of code into multiple lines in my post 

Isn't it possible to use an html tag in order to quote the code ? I saw a lot of correctly formatted code on the old SAS discussion forum.

Thanks!


The only way I have found so far is to paste the code to MS Word and then to here.  It also preserves the syntax coloring.  I would like a more direct way too.

proc summary data=temp nway;

   class id datetime;

   format datetime datetime14.;

   output out=sum1;

   run;

Florent
Quartz | Level 8

Thanks!

So, here is the sample program that I used to save an email as a .msg file:

data _null_;

      currentDate= compress(put(today(), yymmdd10.), '-');

      currentTime= compress(put(time(), time8.), ':');

      call symput('timespan', compress(currentDate || currentTime));

run;

filename vbs "C:\WINDOWS\Temp\SaveEmail_&timespan..vbs" lrecl=256;

data _NULL_;

      file vbs;

      put 'Set objOutlook = CreateObject("Outlook.Application")';

      put 'Set objMailMessage = objOutlook.CreateItem(0)';

      put 'With objMailMessage';

      put '.To = "&sysuserid."';

      put '.Subject = "Test Email"';

      put '.Body = "Hello," & Chr(10) & Chr(10) & _';

      put '"This is a test email." & Chr(10) & Chr(13) & _';

      put '"The purpose of this email is to test that it was correctly saved on your desktop."';

      put ".SaveAs ""C:\Documents and Settings\&Sysuserid.\Desktop\Test_Email_&timespan..msg""";

      put 'End With';

run;

options noxwait xsync;

X "WScript //NoLogo //B C:\WINDOWS\Temp\SaveEmail_&timespan..vbs";

filename ERASEIT pipe "del ""C:\WINDOWS\Temp\SaveEmail_&timespan..vbs""";

data _NULL_;

      infile ERASEIT;

run;

Josephthottan
Calcite | Level 5

@Florent Can you Share the vbs code  for saving email

 

C:\WINDOWS\Temp\SaveEmail_&timespan..vbs";

 

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
  • 8 replies
  • 2851 views
  • 1 like
  • 5 in conversation