Hi,
The following script works exactly as expected except when i try to email
very large files. The emails are are either never sent or never received.
How do compress the NTFS (compress.exe does not work on NTFS files) file to
make it small enough to be emailed? Also how do I uncompress it with a
script when I receive it?
Thanks in Advance,
Rowland

'**********************************************************
'
' *** add client specific constants Here
const FBEGIN = "WEBEXTD"
const FPATH = "C:\Program Files\Microsoft ISA Server\ISALogs\"
const TOADDRESS = "mbox@server.com"
const FROMADDRESS = "server@someserver.com"
'
'**********************************************************

Set oNet = CreateObject("Wscript.Network")
sDomain = oNet.userDomain
eDate=changeDate(date())

strSubject = sDomain & " WEB LOGS " & eDate

set objFSO = CreateObject("Scripting.FileSystemObject")

dp=datepart("w",date())

randomize
upperbound=5
lowerbound=1
do
x = int((upperbound - lowerbound + 1) * Rnd + lowerbound)

select case x
case 1
theDate=date() - (dp+1)
case 2
theDate=date() - (dp+2)
case 3
theDate=date() - (dp+3)
case 4
theDate=date() - (dp+4)
case 5
theDate=date() - (dp+5)
end select

newDate=changeDate(theDate)
webDate=changeToWebDate(newDate)

fileName=FBEGIN & webDate & ".log"
fullPath=FPATH & fileName
loop until objFSO.FileExists(fullPath)=true

Dim iMsg
Set iMsg = CreateObject("CDO.Message")

With iMsg
.from = FROMADDRESS

.To = TOADDRESS

.Subject = strSubject

.TextBody = "Here is The Web Log File. " & fullPath

.AddAttachment(fullPath)

.Send
End With

set iMsg = nothing

function changeToWebDate(strDate)
x=split(strDate,"/",-1)
if len(x(0))=1 then x(0)="0" & x(0)
if len(x(1))=1 then x(1)="0" & x(1)
changeToWebDate=x(2) & x(0) & x(1)
end function

function changeDate(strDate)
fwdSlash=instr(strdate,"/")
hyphen=instr(strDate,"-")
period=instr(strDate,".")

if fwdSlash > 0 then delimiter="/"
if hyphen > 0 then delimiter="-"
if period > 0 then delimiter="."

x=split(strDate,delimiter,-1)

if strcomp(left(x(0),1),"0")=0 then x(0)=right(x(0),1)
if strcomp(left(x(1),1),"0")=0 then x(1)=right(x(1),1)
if len(x(2))=2 then x(2)="20" & x(2)

changeDate=x(0) & "/" & x(1) & "/" & x(2)
end function

Re: compress/uncompress files for email by Rafael

Rafael
Fri Apr 08 19:01:51 CDT 2005

Rowland,

Compression is a local thing. What you are looking for is a way to ZIP the
file.

It is a very different form of compression.

- To zip it, you can use "compress" from the command line

- or you can try to script it. Read:
http://groups-beta.google.com/group/microsoft.public.scripting.vbscript/browse_thread/thread/fa991c99de0da0f4/f5b968c172d2da74?q=vbscript+compress+file&rnum=15#f5b968c172d2da74

hope this helps,
RT

Rafael
"Rowland Long" <rhl@jbay.com> wrote in message
news:OK4VRtFPFHA.3668@TK2MSFTNGP14.phx.gbl...
> Hi,
> The following script works exactly as expected except when i try to email
> very large files. The emails are are either never sent or never received.
> How do compress the NTFS (compress.exe does not work on NTFS files) file
> to make it small enough to be emailed? Also how do I uncompress it with a
> script when I receive it?
> Thanks in Advance,
> Rowland
>
> '**********************************************************
> '
> ' *** add client specific constants Here
> const FBEGIN = "WEBEXTD"
> const FPATH = "C:\Program Files\Microsoft ISA Server\ISALogs\"
> const TOADDRESS = "mbox@server.com"
> const FROMADDRESS = "server@someserver.com"
> '
> '**********************************************************
>
> Set oNet = CreateObject("Wscript.Network")
> sDomain = oNet.userDomain
> eDate=changeDate(date())
>
> strSubject = sDomain & " WEB LOGS " & eDate
>
> set objFSO = CreateObject("Scripting.FileSystemObject")
>
> dp=datepart("w",date())
>
> randomize
> upperbound=5
> lowerbound=1
> do
> x = int((upperbound - lowerbound + 1) * Rnd + lowerbound)
>
> select case x
> case 1
> theDate=date() - (dp+1)
> case 2
> theDate=date() - (dp+2)
> case 3
> theDate=date() - (dp+3)
> case 4
> theDate=date() - (dp+4)
> case 5
> theDate=date() - (dp+5)
> end select
>
> newDate=changeDate(theDate)
> webDate=changeToWebDate(newDate)
>
> fileName=FBEGIN & webDate & ".log"
> fullPath=FPATH & fileName
> loop until objFSO.FileExists(fullPath)=true
>
> Dim iMsg
> Set iMsg = CreateObject("CDO.Message")
>
> With iMsg
> .from = FROMADDRESS
>
> .To = TOADDRESS
>
> .Subject = strSubject
>
> .TextBody = "Here is The Web Log File. " & fullPath
>
> .AddAttachment(fullPath)
>
> .Send
> End With
>
> set iMsg = nothing
>
> function changeToWebDate(strDate)
> x=split(strDate,"/",-1)
> if len(x(0))=1 then x(0)="0" & x(0)
> if len(x(1))=1 then x(1)="0" & x(1)
> changeToWebDate=x(2) & x(0) & x(1)
> end function
>
> function changeDate(strDate)
> fwdSlash=instr(strdate,"/")
> hyphen=instr(strDate,"-")
> period=instr(strDate,".")
>
> if fwdSlash > 0 then delimiter="/"
> if hyphen > 0 then delimiter="-"
> if period > 0 then delimiter="."
>
> x=split(strDate,delimiter,-1)
>
> if strcomp(left(x(0),1),"0")=0 then x(0)=right(x(0),1)
> if strcomp(left(x(1),1),"0")=0 then x(1)=right(x(1),1)
> if len(x(2))=2 then x(2)="20" & x(2)
>
> changeDate=x(0) & "/" & x(1) & "/" & x(2)
> end function
>
>
>