Author Topic: Is It Possible to Email on IP Change  (Read 8224 times)

Offline Silber

  • Posts: 2
Is It Possible to Email on IP Change
« on: August 09, 2005, 03:04:29 »
When my IP changes, I need to update some things other than the DNS record. Is there a way to get an email when 3DWatch sees that the IP changed? If not in the program, is there any other software that can work with 3D to do that?

Thanks.

Offline Thomas

  • Administrator
  • *****
  • Posts: 1254
Is It Possible to Email on IP Change
« Reply #1 on: August 09, 2005, 13:57:42 »
Hi Silber,

You could use the 'Application Launch' feature to run a script that does what you want. There is a VB script example at the end of this message (filename SendMail.vbs).

Thomas
Code: [Select]
'--------------------------------------------------
'
' Sends email from the local SMTP service using CDONTS objects
'
' Usage:
'   sendmail -t <to> -f <from> -s "<subject>" -b "<message>"
'   sendmail [-help|-?]
'
'--------------------------------------------------

Option Explicit
On Error Resume Next

Dim objSendMail, oArgs, ArgNum
Dim strTo, strFrom, strSubject, strBody

Set oArgs = WScript.Arguments
ArgNum = 0

While ArgNum < oArgs.Count
  Select Case LCase(oArgs(ArgNum))
Case "-to","-t":
ArgNum = ArgNum + 1
strTo = oArgs(ArgNum)
Case "-from","-f":
ArgNum = ArgNum + 1
strFrom = oArgs(ArgNum)
Case "-subject","-s":
ArgNum = ArgNum + 1
strSubject = oArgs(ArgNum)
Case "-body","-b":
ArgNum = ArgNum + 1
strBody = oArgs(ArgNum)
Case "-help","-?":
Call DisplayUsage
Case Else:
Call DisplayUsage
  End Select
  ArgNum = ArgNum + 1
Wend

If oArgs.Count=0 Or strTo="" Or strFrom="" Or _
strSubject="" Or strBody="" Then
  Call DisplayUsage
Else
  Set objSendMail = CreateObject("CDONTS.NewMail")
objSendMail.From = strFrom
objSendMail.To = strTo
objSendMail.Subject = strSubject
objSendMail.Body = strBody
objSendMail.Send
  Set objSendMail = Nothing
End If

' Display the usage for this script
Sub DisplayUsage
  WScript.Echo "Usage:" & Chr(10) & _
"  sendmail -t <to address> -f <from address> -s " & _
Chr(34) & "<subject>" & Chr(34) & " -b " & Chr(34) & _
"<message body>" & Chr(34) & Chr(10) & _
"  sendmail [-help|-?]"
  WSCript.Quit
End Sub
Bitte beachten Sie das Urheberrecht und verstoßen Sie nicht gegen von Ihnen akzeptierte Geschäftsbedingungen.
Please don't violate copyright laws and observe the terms that you agreed to.

Offline Silber

  • Posts: 2
Is It Possible to Email on IP Change
« Reply #2 on: August 09, 2005, 14:09:54 »
Thanks for the script. That should do the job.