<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Running a scheduled .vbs file generating two emails in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Running-a-scheduled-vbs-file-generating-two-emails/m-p/809841#M319375</link>
    <description>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</description>
    <pubDate>Tue, 26 Apr 2022 10:33:19 GMT</pubDate>
    <dc:creator>mmohotsi</dc:creator>
    <dc:date>2022-04-26T10:33:19Z</dc:date>
    <item>
      <title>Running a scheduled .vbs file generating two emails</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-a-scheduled-vbs-file-generating-two-emails/m-p/807574#M318418</link>
      <description>&lt;P&gt;Good day&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to schedule a project and run the generated .vbs script.&lt;/P&gt;
&lt;P&gt;The SAS program in the project is also expected to send an email to the customers.&lt;/P&gt;
&lt;P&gt;The problem is that the customers receive two similar emails fwhen the VB script is executed at the scheduled time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I manually run the project and not the VB script, ONLY one email is received by customers.&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data aa;&lt;BR /&gt;input Name $8. Number;&lt;BR /&gt;cards;&lt;BR /&gt;Mighty 23&lt;BR /&gt;Thabo 36&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;options emailsys = SMTP;&lt;BR /&gt;options emailhost =&amp;lt;SMTP&amp;gt;;&lt;BR /&gt;options emailauthprotocol = NONE;&lt;/P&gt;
&lt;P&gt;filename Outbox email;&lt;BR /&gt;Data _null_;&lt;BR /&gt;file Outbox&lt;BR /&gt;to ="&amp;lt;email adress&amp;gt;"&lt;BR /&gt;from ="&amp;lt;email adress&amp;gt;"&lt;BR /&gt;Subject = "Emailed results"; &lt;BR /&gt;put 'Good day ';&lt;BR /&gt;put ' ';&lt;BR /&gt;put 'Kindly find the the data has been done';&lt;BR /&gt;put ' ';&lt;BR /&gt;put 'Warmest regards';&lt;BR /&gt;Put 'Thabo';&lt;BR /&gt;run;&lt;BR /&gt;filename outbox clear;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Apr 2022 11:25:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-a-scheduled-vbs-file-generating-two-emails/m-p/807574#M318418</guid>
      <dc:creator>mmohotsi</dc:creator>
      <dc:date>2022-04-13T11:25:56Z</dc:date>
    </item>
    <item>
      <title>Re: Running a scheduled .vbs file generating two emails</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-a-scheduled-vbs-file-generating-two-emails/m-p/807612#M318436</link>
      <description>&lt;P&gt;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?&lt;/P&gt;</description>
      <pubDate>Wed, 13 Apr 2022 14:49:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-a-scheduled-vbs-file-generating-two-emails/m-p/807612#M318436</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-04-13T14:49:51Z</dc:date>
    </item>
    <item>
      <title>Re: Running a scheduled .vbs file generating two emails</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-a-scheduled-vbs-file-generating-two-emails/m-p/809621#M319275</link>
      <description>&lt;P&gt;Good morning ballardw&lt;/P&gt;
&lt;P&gt;When going through the scheduling process, sas has created the following .vbs script&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Option Explicit&lt;BR /&gt;Dim app&lt;/P&gt;
&lt;P&gt;Call dowork&lt;/P&gt;
&lt;P&gt;'shut down the app&lt;BR /&gt;If not (app Is Nothing) Then&lt;BR /&gt;app.Quit&lt;BR /&gt;Set app = Nothing&lt;BR /&gt;End If&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Sub dowork()&lt;BR /&gt;On Error Resume Next&lt;BR /&gt;'----&lt;BR /&gt;' Start up Enterprise Guide using the project name&lt;BR /&gt;'----&lt;BR /&gt;Dim prjName&lt;BR /&gt;Dim prjObject&lt;/P&gt;
&lt;P&gt;prjName = "C:\Users\mmohotsi\Documents\SASImplementation\Learning_Curve\Project_Scheduling.egp" 'Project Name&lt;BR /&gt;&lt;BR /&gt;Set app = CreateObject("SASEGObjectModel.Application.8.1")&lt;BR /&gt;If Checkerror("CreateObject") = True Then&lt;BR /&gt;Exit Sub&lt;BR /&gt;End If&lt;BR /&gt;&lt;BR /&gt;'-----&lt;BR /&gt;' open the project&lt;BR /&gt;'-----&lt;BR /&gt;Set prjObject = app.Open(prjName,"")&lt;BR /&gt;If Checkerror("app.Open") = True Then&lt;BR /&gt;Exit Sub&lt;BR /&gt;End If&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;'-----&lt;BR /&gt;' run the project&lt;BR /&gt;'-----&lt;BR /&gt;prjObject.run&lt;BR /&gt;If Checkerror("Project.run") = True Then&lt;BR /&gt;Exit Sub&lt;BR /&gt;End If&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;'-----&lt;BR /&gt;' Save the new project&lt;BR /&gt;'-----&lt;BR /&gt;prjObject.Save&lt;BR /&gt;If Checkerror("Project.Save") = True Then&lt;BR /&gt;Exit Sub&lt;BR /&gt;End If&lt;BR /&gt;&lt;BR /&gt;'-----&lt;BR /&gt;' Close the project&lt;BR /&gt;'-----&lt;BR /&gt;prjObject.Close&lt;BR /&gt;If Checkerror("Project.Close") = True Then&lt;BR /&gt;Exit Sub&lt;BR /&gt;End If&lt;BR /&gt;&lt;BR /&gt;End Sub&lt;/P&gt;
&lt;P&gt;Function Checkerror(fnName)&lt;BR /&gt;Checkerror = False&lt;BR /&gt;&lt;BR /&gt;Dim strmsg&lt;BR /&gt;Dim errNum&lt;BR /&gt;&lt;BR /&gt;If Err.Number &amp;lt;&amp;gt; 0 Then&lt;BR /&gt;strmsg = "Error #" &amp;amp; Hex(Err.Number) &amp;amp; vbCrLf &amp;amp; "In Function " &amp;amp; fnName &amp;amp; vbCrLf &amp;amp; Err.Description&lt;BR /&gt;'MsgBox strmsg 'Uncomment this line if you want to be notified via MessageBox of Errors in the script.&lt;BR /&gt;Checkerror = True&lt;BR /&gt;End If&lt;BR /&gt;&lt;BR /&gt;End Function&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Apr 2022 06:08:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-a-scheduled-vbs-file-generating-two-emails/m-p/809621#M319275</guid>
      <dc:creator>mmohotsi</dc:creator>
      <dc:date>2022-04-25T06:08:41Z</dc:date>
    </item>
    <item>
      <title>Re: Running a scheduled .vbs file generating two emails</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-a-scheduled-vbs-file-generating-two-emails/m-p/809792#M319347</link>
      <description>&lt;P&gt;So are you getting the second email because the error number is not equal to zero? If so what is the error number?&lt;/P&gt;</description>
      <pubDate>Mon, 25 Apr 2022 23:40:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-a-scheduled-vbs-file-generating-two-emails/m-p/809792#M319347</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2022-04-25T23:40:11Z</dc:date>
    </item>
    <item>
      <title>Re: Running a scheduled .vbs file generating two emails</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-a-scheduled-vbs-file-generating-two-emails/m-p/809841#M319375</link>
      <description>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</description>
      <pubDate>Tue, 26 Apr 2022 10:33:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-a-scheduled-vbs-file-generating-two-emails/m-p/809841#M319375</guid>
      <dc:creator>mmohotsi</dc:creator>
      <dc:date>2022-04-26T10:33:19Z</dc:date>
    </item>
    <item>
      <title>Re: Running a scheduled .vbs file generating two emails</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-a-scheduled-vbs-file-generating-two-emails/m-p/810481#M319602</link>
      <description>&lt;P&gt;I suggest you raise a Tech Support track on this as they are in the best position to help.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 20:21:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-a-scheduled-vbs-file-generating-two-emails/m-p/810481#M319602</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2022-04-28T20:21:57Z</dc:date>
    </item>
  </channel>
</rss>

