Jump to content

what's wrong here?


mlloz
 Share

Recommended Posts

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?

CODE
If @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

yes, its working..

but I think there's a better code than

If @error Then RunAgain()

and

WinWait('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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...