Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


RE: Sending E-Mails

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,44892
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> RE: Sending E-Mails
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: <<   < prev  1 [2]
Login
Message << Older Topic   Newer Topic >>
 RE: Sending E-Mails - 3/26/2007 12:58:06 AM   
  ginolard


Posts: 1044
Score: 21
Joined: 8/10/2005
Status: offline
Well that won't work because File.Size is an integer and you are asking it if it equals the string "1 bytes"

To perform any sort of error checking you need On Error Resume Next (this essentially tells the script to continue running if it encounters an error). As mentioned in the other thread you "wrap" the potentially problem code in On Error Resume Next and On Error Goto 0 (this turns off On Error Resume Next).

To use the example from the other thread....

   On Error Resume Next
      Set oTS = oFS.OpenTextFile("c:\temp\test.txt" )
      nErrNumber = Err.Number               ' Copy the Err info (cleared by OEG0) to
    sErrDescription = Err.Description    ' two simple variables
      On Error Goto 0
  If nErrNumber <> 0 Then
   wscript.echo sErrDescription
   end if




  

_____________________________

Author of ManagePC - http://managepc.net
AD Query Template - http://www.visualbasicscript.com/m_40609/tm.htm
Consolidated Scripting Framework - http://www.visualbasicscript.com/m_59109/tm.htm

(in reply to morpheus83uk)
 
 
Post #: 21
 
 RE: Sending E-Mails - 3/26/2007 1:18:13 AM   
  morpheus83uk

 

Posts: 320
Score: 0
Joined: 8/21/2006
Status: offline
Thanks for that.

What would I need to change for it to look at the size and if its bigger then run the E-Mail code and if its not 1bytes then it skips it and carries on?


      

So the above code should work? and not pop anything up on screen and just plop it all into the text file?

Many Thanks

James


(in reply to ginolard)
 
 
Post #: 22
 
 RE: Sending E-Mails - 3/26/2007 1:53:41 AM   
  ginolard


Posts: 1044
Score: 21
Joined: 8/10/2005
Status: offline
What do you want to do exactly?

As it stands your code

1) Checks if the file exists
2) Opens it
3) Sees if there was an error

Even if it were 0 bytes long, it would still open it so there will never be an error

Now, if you wanted to check the filesize you need to use the GetFile method of FSO and check the Size property

_____________________________

Author of ManagePC - http://managepc.net
AD Query Template - http://www.visualbasicscript.com/m_40609/tm.htm
Consolidated Scripting Framework - http://www.visualbasicscript.com/m_59109/tm.htm

(in reply to morpheus83uk)
 
 
Post #: 23
 
 RE: Sending E-Mails - 3/26/2007 2:29:34 AM   
  morpheus83uk

 

Posts: 320
Score: 0
Joined: 8/21/2006
Status: offline
Hello,

I would like it to NOT display an error on screen...

I would like it to write the error information into the text file...

So rather than a massive error message box come up on screen I would like it to put the error information into that text file....

Does that make sense?

So it will check for the files existance... great it should be there anyways :)

Opens it only if an error occurs

Then it should Write the error information into there...

As for the filesize checking thing I thought thats what the code was doing :


      

Many Thanks

James

(in reply to ginolard)
 
 
Post #: 24
 
 RE: Sending E-Mails - 3/26/2007 2:43:04 AM   
  dm_4ever


Posts: 2593
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
Like ginolard said, this: If f.Size >= "1 Bytes" Then
is trying to compare a number with a string so it should actually be more like this: If f.Size >= 1 Then

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to morpheus83uk)
 
 
Post #: 25
 
 RE: Sending E-Mails - 3/26/2007 2:51:50 AM   
  morpheus83uk

 

Posts: 320
Score: 0
Joined: 8/21/2006
Status: offline
Ohhh Right sorry!!!

I feel so stupid now!

Thanks for that

James

(in reply to dm_4ever)
 
 
Post #: 26
 
 RE: Sending E-Mails - 3/26/2007 4:01:56 AM   
  morpheus83uk

 

Posts: 320
Score: 0
Joined: 8/21/2006
Status: offline
Hello,

Just wondering on what I need to change in my error logging code to make it do what I need it to do?

Many Thanks

James

(in reply to morpheus83uk)
 
 
Post #: 27
 
 RE: Sending E-Mails - 3/26/2007 7:11:53 PM   
  ginolard


Posts: 1044
Score: 21
Joined: 8/10/2005
Status: offline

      

OK, well, this code doesn't really do anything.  It checks if the filesize of the errorlog is >= to the string "1 bytes" and, if so, tries to write stuff to whatever objfile is.  What is objfile?

Are you sure you are meant to be checking the size of the error logfile? 

_____________________________

Author of ManagePC - http://managepc.net
AD Query Template - http://www.visualbasicscript.com/m_40609/tm.htm
Consolidated Scripting Framework - http://www.visualbasicscript.com/m_59109/tm.htm

(in reply to morpheus83uk)
 
 
Post #: 28
 
 RE: Sending E-Mails - 3/26/2007 9:01:06 PM   
  morpheus83uk

 

Posts: 320
Score: 0
Joined: 8/21/2006
Status: offline
Hello,

My Code currently stands at


      

It needs to check the size of the error log file then it will know there is information to send... if the file is empty then it will do nothing and stat at 0 bytes...

Objfile is Maintenance_Log.txt which is a log file of each activity which has been completed. it gets displayed in a html file for the users to see so they can see the script is doing something....  Does this make more sense?

Does this make sense?

And then there is the matter of the other error logging stuff whcih puts everything into a text file and dosent display the error message on screen...

Many Thanks

James

(in reply to ginolard)
 
 
Post #: 29
 
 
Page:  <<   < prev  1 [2]
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> RE: Sending E-Mails Page: <<   < prev  1 [2]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts