active X script Microsoft compilation Error in DTS

  •  

    I found the problem. just take the & vbCrLf  out. Thx.

    this is my first active x script. I do not understand why it give me error while I parse the active X script in my dts package. It stop at the line objMail.To =    "fao@abc" with error code 0 error description: it expected statement description. Error source Microsoft compilation error.

     

     

     

     

    Function Main()

            Dim oFSO, oConn, sFileName, oFile

     ' Get the filename from my Text File connection called "Text File (Source)"

     Set oConn = DTSGlobalVariables.Parent.Connections("Text File (Source)")

     sFilename = oConn.DataSource

     Set oConn = Nothing

     Set oFSO = CreateObject("Scripting.FileSystemObject")

     ' Check File Exists first

     If Not oFSO.FileExists(sFilename) Then

      ' SQL Server 2000 Only, log error

      ' Return Error

                    EmailNotify("FileNotExist")

      Main = DTSTaskExecResult_Failure

     Else

      ' Get file object

      Set oFile = oFSO.GetFile(sFilename)

     

      ' Check age of file is less than 24 hours

      If DateDiff("h", oFile.DateLastModified, Now) >= 24 Then

       ' SQL Server 2000 Only, log error

                     EmailNotify("Rob")

       ' Return Error

       Main = DTSTaskExecResult_Failure

      Else

       ' Return Success

       Main = DTSTaskExecResult_Success 

      End If  

     End If

     

     Set oFile = Nothing

     Set oFSO = Nothing

    End Function

    Function   EmailNotify(s)

          Dim  objMail , strEmailBody, strA

          Set objMail = CreateObject("CDONTS.NewMail")     

       

     ' Set Message Text, including a global variable value

           if s="FileNotExist" then

            

           strEmailBody = " \\Dbase-svr\shared\Doc_master\Doc.txt is not existed"

           else

        

           'Create the body of the email

           strEmailBody = " \\Dbase-svr\shared\Doc_master\Doc.txt is upated existed"

     & vbCrLf

       end if

           objMail.To =    "fao@abc"

           objMail.Subject = "Doctor Master Update Report"

           'Set the Importance to High

           objMail.Importance = 2

           objMail.Subject = strEmailBody

           objMail.Send

     

     ' Clean Up

     Set objMail = Nothing

    End Function

     

     

  • Thanks for the update and not deleting the post.

  • good that you solved the problem yourself.

     

    but if you need the vbcrlf, you can have it. Either type the whole thing in one line or use the 'line split character (_) underscore to keep it in a separate line

     

           strEmailBody = " \\Dbase-svr\shared\Doc_master\Doc.txt is upated existed" _

     & vbCrLf

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply