I set up the DTS in my server which install smtp mail server.
DTS will try to import the text . Before I import , I want to check whether the file is update otherwise I will email operator to update. if update it, then import.
On the workflow , i added this active script. The mail part is not working. I have cdo install in my computer. I have stored procedure to email . I do not know why. Thx.
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) >= 160 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"
end if
'objMail.To = "aBC@abc.com"
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
DTS will try to import the text . Before I import , I want to check whether the file is update otherwise I will email operator to update. if update it, then import.
On the workflow , i added this active script. The mail part is not working. I have cdo install in my computer. I have stored procedure to email . I do not know why. Thx.
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) >= 160 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"
end if
'objMail.To = "aBC@abc.com"
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