austinboy01
Sun May 13 23:08:06 CDT 2007
Thank You Ayush! This is the most progress I've made thanks to you! Two things:
1. The folders/sub folders will have over 20,000 of these .pdf files. How do
I edit your code to only give me a count and write a statement on the
list/e-mail to say something like: "There are 23,269 pdf files in the Z:\C89
folder"
2. The email portion didn't work. Do I need to include our mail server name
in the cdo.message part such as: cdm.From =
"al.garcia@servername.companyname.net"
Woo Hoo!
"Ayush" <"ayushmaan.j[aatt]gmail.com" wrote:
> [austinboy01]s message :
> > Hey guys, I'm new to vbs. (Don't they all say that?) I'm trying to automate a
> > task at work using vbs. Basically, I need a count of files from a folder AND
> > sub-folders for all .pdf files created today. The path is Z:\C89\ and it
> > remains constant and the file names are formatted as such: xxxx20070518.pdf,
> > where the current date + 5 days is embedded into the file name. (I can't get
> > the wildcard to work-that's why I thought I'd mention it.) Next, I'd like for
> > the script to send me the results in an email. e.g. "The C89 folder has 50
> > pdf files" We use Windows Exchange on XP/2003 here. I've tried to piece
> > together code from different sites, but I always end up with some error. I
> > don't mind cracking open a book and learning vbs from scratch-which I intend
> > to do, but I'm up against a deadline.
> > Regards~
>
>
> folder="Z:\C89"
> ext=".pdf"
>
> Set fs=CreateObject("Scripting.FileSystemObject")
> list=""
> LoopFiles fs.GetFolder(folder)
> On Error Resume Next
> Sub LoopFiles(Folder)
> For Each File in Folder.Files
> If Right(File.Name,Len(ext))=ext Then
> If DateDiff("d",File.DateCreated,Now)=0 Then
> list=list & File.Path & vbNewLine
> End If
> End If
> Next
> For Each SubFolder in Folder.SubFolders
> LoopFiles SubFolder
> Next
> End Sub
>
> msgbox list
>
> Set cdm = CreateObject("CDO.Message")
> cdm.Subject = "SUBJECT HERE"
> cdm.From = "ENTER FROM HERE"
> cdm.To = "TO HERE"
> cdm.TextBody = list
> cdm.Send
>
> Good Luck, Ayush.
> --
> VBScript, JScript, WSH Reference :
http://www.devguru.com/
>