BookmarkSubscribeRSS Feed
mmohotsi
Obsidian | Level 7

Good day

 

I am trying to schedule a project and run the generated .vbs script.

The SAS program in the project is also expected to send an email to the customers.

The problem is that the customers receive two similar emails fwhen the VB script is executed at the scheduled time.

 

When I manually run the project and not the VB script, ONLY one email is received by customers.

Is there a way for ensuring that only one email is received by the customers when the VB script is executed at the scheduled time? The prototype SAS programme is below.

 

data aa;
input Name $8. Number;
cards;
Mighty 23
Thabo 36
;
run;

options emailsys = SMTP;
options emailhost =<SMTP>;
options emailauthprotocol = NONE;

filename Outbox email;
Data _null_;
file Outbox
to ="<email adress>"
from ="<email adress>"
Subject = "Emailed results";
put 'Good day ';
put ' ';
put 'Kindly find the the data has been done';
put ' ';
put 'Warmest regards';
Put 'Thabo';
run;
filename outbox clear;

5 REPLIES 5
ballardw
Super User

I don't see anything here related to VBS. It sounds like you have something else scheduling the VBS run, not SAS. So SAS is going to have a very hard time intervening in a different program. What actual schedules the VBS to run?

mmohotsi
Obsidian | Level 7

Good morning ballardw

When going through the scheduling process, sas has created the following .vbs script 

 

 

Option Explicit
Dim app

Call dowork

'shut down the app
If not (app Is Nothing) Then
app.Quit
Set app = Nothing
End If


Sub dowork()
On Error Resume Next
'----
' Start up Enterprise Guide using the project name
'----
Dim prjName
Dim prjObject

prjName = "C:\Users\mmohotsi\Documents\SASImplementation\Learning_Curve\Project_Scheduling.egp" 'Project Name

Set app = CreateObject("SASEGObjectModel.Application.8.1")
If Checkerror("CreateObject") = True Then
Exit Sub
End If

'-----
' open the project
'-----
Set prjObject = app.Open(prjName,"")
If Checkerror("app.Open") = True Then
Exit Sub
End If


'-----
' run the project
'-----
prjObject.run
If Checkerror("Project.run") = True Then
Exit Sub
End If


'-----
' Save the new project
'-----
prjObject.Save
If Checkerror("Project.Save") = True Then
Exit Sub
End If

'-----
' Close the project
'-----
prjObject.Close
If Checkerror("Project.Close") = True Then
Exit Sub
End If

End Sub

Function Checkerror(fnName)
Checkerror = False

Dim strmsg
Dim errNum

If Err.Number <> 0 Then
strmsg = "Error #" & Hex(Err.Number) & vbCrLf & "In Function " & fnName & vbCrLf & Err.Description
'MsgBox strmsg 'Uncomment this line if you want to be notified via MessageBox of Errors in the script.
Checkerror = True
End If

End Function

 

 

 

 

 

 

SASKiwi
PROC Star

So are you getting the second email because the error number is not equal to zero? If so what is the error number?

mmohotsi
Obsidian | Level 7
As a SAS programming NOVICE, I am not in a position to tell what the Error number is. The script was generated in the background and I only copied and pasted on my reply. I am therefore not sure how to get the error number from Enterprise Guide. What I can say is that in my project, I have two SAS programmes. SAS programme 1 generates the report and then SAS programme 2 sends the email with the report. Not sure if the transition from programme 1 to programme 2 could have some impact or not
SASKiwi
PROC Star

I suggest you raise a Tech Support track on this as they are in the best position to help.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 5 replies
  • 502 views
  • 0 likes
  • 3 in conversation