Re: help emailing this script

Tech-Archive recommends: Fix windows errors by optimizing your registry



Thanks pegasus,

Where do I add this in my script?

"Pegasus (MVP)" wrote:

You could use this code to generate an EMail note and
optionally add an attachment:
schema = "http://schemas.microsoft.com/cdo/configuration/";

Set objEmail = CreateObject("CDO.Message")
With objEmail
.From = "arthur@xxxxxxxxxx"
.To = "andrew@xxxxxxxxxx"
.Subject = "Test Mail"
.Textbody = "The quick brown fox " & Chr(10) & "jumps over the lazy dog"
.AddAttachment "d:\Testfile.txt"
With .Configuration.Fields
.Item (schema & "sendusing") = 2
.Item (schema & "smtpserver") = "mail.arthur.com"
.Item (schema & "smtpserverport") = 25
.Item (schema & "smtpauthenticate") = cdoBasic
.Item (schema & "sendusername") = "arthur@xxxxxxxxxx"
.Item (schema & "sendpassword") = "somepassword"
End With
.Configuration.Fields.Update
.Send
End With


"arthursc" <arthursc@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:FEECF420-1D45-47FA-8473-D91BBE933C9B@xxxxxxxxxxxxxxxx
Thanks...But,

How do I add this to my script below and attatch the output?

"ThatsIT.net.au" wrote:

Here is an example I made for someone else,
http://dev.thatsit.net.au/samples/wsh/thatsit/messaging/sendemailwithdelveryreceipt.aspx

remove this line if you don't want a read receipt
.DSNOptions = CDO_SUCCESS_FAIL_DELAY


"arthursc" <arthursc@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:D4D0A5F8-766F-4CF1-AE68-421D838E4245@xxxxxxxxxxxxxxxx
Hi

I have the following script that I want to email the output in html to
some
users.

I am not a vbscripting guy, so would not know where to start.

Your help is appreciated.

Option Explicit

const strComputer = "."
const strReport = "c:\diskspace.txt"


Dim objWMIService, objItem, colItems
Dim strDriveType, strDiskSize, txt

Set objWMIService = GetObject("winmgmts:\\" & strComputer &
"\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_LogicalDisk
WHERE DriveType=3")
txt = "Drive" & vbtab & "Size" & vbtab & "Used" & vbtab & "Free" &
vbtab &
"Free(%)" & vbcrlf
For Each objItem in colItems

DIM pctFreeSpace,strFreeSpace,strusedSpace

pctFreeSpace = INT((objItem.FreeSpace / objItem.Size) * 1000)/10
strDiskSize = Int(objItem.Size /1073741824) & "Gb"
strFreeSpace = Int(objItem.FreeSpace /1073741824) & "Gb"
strUsedSpace = Int((objItem.Size-objItem.FreeSpace)/1073741824) & "Gb"
txt = txt & objItem.Name & vbtab & strDiskSize & vbtab & strUsedSpace &
vbTab & strFreeSpace & vbtab & pctFreeSpace & vbcrlf

Next

writeTextFile txt, strReport
wscript.echo "Report written to " & strReport & vbcrlf & vbcrlf & txt

' Procedure to write output to a text file
private sub writeTextFile(byval txt,byval strTextFilePath)
Dim objFSO,objTextFile

set objFSO = createobject("Scripting.FileSystemObject")

set objTextFile = objFSO.CreateTextFile(strTextFilePath)

objTextFile.Write(txt)

objTextFile.Close
SET objTextFile = nothing
end sub




.



Relevant Pages

  • Re: help emailing this script
    ... script by creating a number of subroutines like so. ... Dim objWMIService, objItem, colItems ... Sub GetDiskParms ... set objTextFile = objFSO.CreateTextFile ...
    (microsoft.public.scripting.vbscript)
  • Re: help emailing this script
    ... Below is the script I have now created along ... Dim objWMIService, objItem, colItems ... Sub GetDiskParms ... set objTextFile = objFSO.CreateTextFile ...
    (microsoft.public.scripting.vbscript)
  • Re: help emailing this script
    ... sub WriteTextFile ... set objTextFile = objFSO.CreateTextFile ... Below is the script I have now created ... Dim objWMIService, objItem, colItems ...
    (microsoft.public.scripting.vbscript)
  • Re: help emailing this script
    ... How do I add this to my script below and attatch the output? ... Dim objWMIService, objItem, colItems ... private sub writeTextFile ... set objTextFile = objFSO.CreateTextFile ...
    (microsoft.public.scripting.vbscript)
  • Re: help emailing this script
    ... You could use this code to generate an EMail note and ... Set objEmail = CreateObject ... Dim objWMIService, objItem, colItems ... set objTextFile = objFSO.CreateTextFile ...
    (microsoft.public.scripting.vbscript)