mlloz Posted February 4, 2008 Share Posted February 4, 2008 hello, I'm trying to know my workstation IP addresses when its changed, i've wrote this code, is it correct? or its better to change some of it? CODEIf @error Then RunAgain() Global $a Global $b Global $c Global $d Global $e Global $f Global $g Global $h $a = "smtp.gmail.com" $b = "username@gmail.com" $c = "password" Func Emailx($d, $e, $f, $g) If @error Then RunAgain() $h = ObjCreate ("CDO.Message") With $h .Subject = $f .Sender = $d .From = $d .To = $e .TextBody = $g ;~ .AddAttachment ("C:\Documents and Settings\myname\Desktop\files\file.txt");needs full path- optional EndWith With $h.Configuration.Fields .Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 .Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $a .Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465 .Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 .Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $b .Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $c .Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 90 .Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True .Update EndWith $h.Send Return EndFunc Func SendE() If @error Then RunAgain() Emailx("My Name", "to@company.com", @ComputerName, @IPAddress1 & " | " & @IPAddress2 & " | " & @IPAddress3 & " | " & @IPAddress4) EndFunc Func RunAgain() Run(@ScriptFullPath) Exit EndFunc SendE() WinWait('Connecting') WinWaitClose('Connecting') RunAgain() Link to comment Share on other sites More sharing options...
mlloz Posted February 4, 2008 Author Share Posted February 4, 2008 hello.. anyone there? Link to comment Share on other sites More sharing options...
weaponx Posted February 4, 2008 Share Posted February 4, 2008 hello..anyone there?Does it work? You didn't say what the problem is. Link to comment Share on other sites More sharing options...
mlloz Posted February 4, 2008 Author Share Posted February 4, 2008 yes, its working.. but I think there's a better code than If @error Then RunAgain() and WinWait('Connecting') WinWaitClose('Connecting') RunAgain() Link to comment Share on other sites More sharing options...
weaponx Posted February 4, 2008 Share Posted February 4, 2008 yes, its working..but I think there's a better code thanIf @error Then RunAgain()andWinWait('Connecting')WinWaitClose('Connecting')RunAgain()You're correct about the RunAgain. I would wrap the first part of the code in its own function called Function Main() or something, then instead of launching the script again, use Main() in place of RunAgain(). Link to comment Share on other sites More sharing options...
mlloz Posted February 4, 2008 Author Share Posted February 4, 2008 ok, but sometimes it is generating an error and exit the script.. so how can I avoid that? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now