0

我有一个每周日创建索引的程序。周日会创建一个文件夹,该文件夹以带有 .001 后缀的日期命名。格式为 YYYYMMDD.001

示例:20130929.001

在该文件夹中创建了 4 个文件夹,它们始终具有相同的名称:TEXT1 TEXT2 TEXT3 TEXT4

我希望有一个脚本来验证该文件夹是否正在创建,如果其中一个子文件夹没有退出,那么将发送一封电子邮件。

这个想法是安排脚本在同一日期运行,但在创建文件夹之后。如果预期的文件夹完成退出,则会发出通知。

我的问题是处理变量日期路径的第一部分和最后一部分是一致的,但是带有日期的日期文件夹每周都会更改。

N:\apps\WORLDOX\isysdb\drive_n\Text\.001\TEXT1

任何建议,将不胜感激。

谢谢,榆木

4

1 回答 1

0

此代码检查文件夹是否存在。如果没有将发送邮件。

Sub TestFolder()

    Dim fso As Object, MyFolder As String
    Dim folder1 As String, folder2 As String, folder3 As String, folder4 As String
    Set fso = CreateObject("Scripting.FileSystemObject")

    MyFolder = "C:\ YYYYMMDD.001\"

    folder1 = MyFolder & "TEXT1"
    folder2 = MyFolder & "TEXT2"
    folder3 = MyFolder & "TEXT3"
    folder4 = MyFolder & "TEXT4"

    If fso.FolderExists(folder1) = False Then
          SendMail "TEXT1"
    ElseIf fso.FolderExists(folder2) = False Then
         SendMail "TEXT2"
    ElseIf fso.FolderExists(folder3) = False Then
          SendMail "TEXT3"
    ElseIf fso.FolderExists(folder4) = False Then
          SendMail "TEXT4"
    End If


End Sub


Sub SendMail(folderName)

    Dim iMsg As Object
    Dim iConf As Object
    Dim Flds As Variant


    Set iMsg = CreateObject("CDO.Message")
    Set iConf = CreateObject("CDO.Configuration")

    iConf.Load -1
    Set Flds = iConf.Fields

    With Flds
        .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
        .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "ddddd"
        .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
        .Update
    End With

    With iMsg

        Set .Configuration = iConf
        .To = "test@gmail.com"
        .From = "test@gmail.com"
        .Subject = folderName & "does not exist" & " " & Date & " " & Time
        .TextBody = folderName & "does not exist" & " " & Date & " " & Time
        .Send
    End With

    Set iMsg = Nothing
    Set iConf = Nothing

End Sub
于 2013-09-30T17:01:20.433 回答