Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Emailing a File..

Status
Not open for further replies.

Woolers

Technical User
Jan 11, 2005
56
GB
Guys,

Can someone point me in the right direction on this ?

Set objNetwork = CreateObject("WScript.Network")
Set WshShell = CreateObject("Wscript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
dtmThisDay = "01"
dtmThisMonth = Month(Date)
dtmThisYear = Year(Date)
strcom1 = "Uptime /d:"
strcommand = strcom1 & dtmThisDay & "/" & dtmThisMonth & "/" & dtmThisYear & " > "
strOutput = "Uptime-" & dtmThisDay & "-" & dtmThisMonth & "-" & dtmThisYear & ".txt"
strComputer = "."
MyLine = "cmd.exe /c " & strcommand & strOutput

WshShell.Run MyLine

Set objFile = objFSO.OpenTextFile(strOutput, 1)
strLine = objFile.ReadAll
objFile.Close
Set objFile = Nothing
Wscript.Sleep 600

Set objEmail = CreateObject("CDO.Message")
objEmail.From = "blah blah"
objEmail.To = "my email add"
objEmail.Subject = "server Monthly Uptime Report"
objEmail.Textbody = strLine
objEmail.Send
Set objEmail = Nothing

This creates the file etc but when it comes to the email part i get an error >>>
D:\Uptime\uptime.vbs(28, 1) CDO.Message.1: The process cannot access the file because it is being used by another process.

I've closed the file so why's it still in use?
TIA

Keyboard Not Detected.....
Press F1 to Continue.
:}
 
Replace this:
WshShell.Run MyLine
By this:
WshShell.Run MyLine, 1, True

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thank you, I'll give it a try & let you know how I get on.

Keyboard Not Detected.....
Press F1 to Continue.
:}
 
Thanks,

Worked great - I had to fudge it slightly but now works.

Thank you. :)

Keyboard Not Detected.....
Press F1 to Continue.
:}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top