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;
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?
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
So are you getting the second email because the error number is not equal to zero? If so what is the error number?
I suggest you raise a Tech Support track on this as they are in the best position to help.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.