The script that gets the extranet IP and sends to the specified mailbox _autoit

Source: Internet
Author: User
Tags error code sleep
Cloud Habitat community compiled EXE file, convenient for everyone to directly use the download address http://www.jb51.net/softs/44627.html

The contents of the configuration file are as follows:
Copy Code code as follows:

Configuration file Code
Recipient
Recipient address =
Message Header =
[Sender]
Mailbox =
Password =

Core code:
Copy Code code as follows:

#region Autoit3wrapper parameters (commonly used parameters)
#AutoIt3Wrapper_Icon =d:\ico\3444\2222.ico icon, support Exe,dll,ico
#AutoIt3Wrapper_OutFile =getip_sendmail.exe; output file name
#AutoIt3Wrapper_OutFile_Type =exe; file type
#AutoIt3Wrapper_Compression = 4; compression level
#AutoIt3Wrapper_UseUpx =y; using compression
#AutoIt3Wrapper_Res_Comment =; note
#AutoIt3Wrapper_Res_Description =; more information
#AutoIt3Wrapper_Res_Fileversion =; file version
#AutoIt3Wrapper_Res_FileVersion_AutoIncrement =p, Automatic Update version
#AutoIt3Wrapper_Res_LegalCopyright = Copyright
#AutoIt3Wrapper_Change2CUI =n; The program that modifies the output is Cui (console program)
; #AutoItAutoIt3Wrapper_Res_Field =autoit version|%autoitver%; custom resource Segments
; #AutoIt3Wrapper_Run_Tidy =; Script collation
; #AutoIt3Wrapper_Run_Obfuscator =; code obfuscation
; #AutoIt3Wrapper_Run_AU3Check =; Grammar check
; #AutoIt3Wrapper_Run_Before =; before running
; #AutoIt3Wrapper_Run_After =; after running
#endregion autoit3wrapper parameters (commonly used parameters)
#include <file.au3>
#include <Inet.au3>
#include <Date.au3>
; Prevent duplicate runs.
$g _szversion = ' Get the extranet IP and send to the specified mailbox '
If winexists ($g _szversion) Then
Exit
EndIf
Autoitwinsettitle ($g _szversion)

; Pallet Events
Opt ("Trayoneventmode", 1); Pallet Event Notification
Opt ("Traymenumode", 1); The default menu item (script Pause/exit) will not be displayed paused/exit.
Traycreateitem ("Send")
Trayitemsetonevent ( -1, ' _sendmail ')
$exititem = Traycreateitem ("Exit program")
Trayitemsetonevent ($exititem, "_exit")
Traysetclick (16); Tray menu is displayed only if you click the Second mouse button (the default right key)
Traysettooltip (' Get the extranet IP and send to the specified mailbox ')
Traysetstate ()

Global $testIp
Global $oMyRet [2]
Global $oMyError = objevent ("Autoit.error", "Myerrfunc")

$s _toaddress = Iniread (@ScriptDir & "\config.ini", ' addressee ', ' recipient address ', '-1 '); recipient address
$s _subject = Iniread (@ScriptDir & "\config.ini", ' addressee ', ' mail title ', '-1 '); message headers
Traytip ("Ready", "Recipient address:" & $s _toaddress _
& @CRLF & "Mail title:" & $s _subject, 5, 1)

_sendmail (); Send mail

Adlibregister (' _reducememory ', 1000 * 10); 10 seconds to organize the memory once

Adlibregister (' _sendmail ', 1000*15)

While 1
Sleep (3000)
Wend

Func _exit ()
Exit
Endfunc; ==>_exit.

; Send mail ====================================================================
Func _sendmail ()
$s _smtpserver = "smtp.163.com"; SMTP server
$s _fromname = "bbs.wglm.net"; Mail Sender
$s _fromaddress = Iniread (@ScriptDir & "\config.ini", ' senders ', ' mailboxes ', '-1 '); Mail Sender Address
$s _toaddress = Iniread (@ScriptDir & "\config.ini", ' addressee ', ' recipient address ', '-1 '); 19377708@qq.com "; recipient address
$s _subject = Iniread (@ScriptDir & "\config.ini", ' addressee ', ' mail title ', '-1 '); AU3 message Send test "; message headers
Todo
$Getip = _getip (); extranet IP
Sleep (300)
Traytip ("Hint", ' getting the extranet IP ', 5, 1)
Until $Getip <>-1

If $testIp = $Getip Then
Traytip ("Hint", the ' extranet IP ' and the last sent ' & @CRLF & ' program will not be sent repeatedly. ', 5, 1)
return; MsgBox (0, ', $Getip)
EndIf
$testIp = $Getip
$as _body = "Extranet IP:" & $Getip & @CRLF & "Send time:" & _nowdate () & "" & _nowtime (), message body; get the extranet IP
$s _attachfiles = ""; Attachment address
$s _ccaddress = ""; cc address
$s _bccaddress = ""; Bcc address
$s _username = Iniread (@ScriptDir & "\config.ini", ' senders ', ' mailboxes ', '-1 '); user name
$s _password = Iniread (@ScriptDir & "\config.ini", ' sender ', ' Password ', '-1 ');
$IPPort = 25; send port, Gmail uses a send port of 465
$ssl = 0
$RC = _inetsmtpmailcom ($s _smtpserver, $s _fromname, $s _fromaddress, $s _toaddress, $s _subject, $as _body, $s _attachfiles, $s _ccaddress, $s _bccaddress, $s _username, $s _password, $IPPort, $ssl)
If @error Then
_filewritelog (@ScriptDir & "\mailsendlog.log", "Mail Send failure error code: & @error &" description: "& $RC)
Traytip ("Send Mail Failed", "Error code:" & @error _
& @CRLF & "description:" & $RC, 5, 1)
Else
_filewritelog (@ScriptDir & "\mailsendlog.log", "Mail sent to successful recipient address:" & $s _toaddress & "message title: & $s _subject &A mp "Message body:" & $as _body)
Traytip ("Mail sent successfully", "Recipient address:" & $s _toaddress _
& @CRLF & "Mail title:" & $s _subject _
& @CRLF & "message body:" & $as _body, 5, 1)
EndIf

Endfunc; ==>_sendmail.

Func _inetsmtpmailcom ($s _smtpserver, $s _fromname, $s _fromaddress, $s _toaddress, $s _subject = "", $as _body = "", $s _attach Files = "", $s _ccaddress = "", $s _bccaddress = "", $s _username = "", $s _password = "", $IPPort =, $ssl = 0)
$objEmail = Objcreate ("CDO". Message ")
$objEmail. From = ' "' & $s _fromname & '" < ' & $s _fromaddress & ' > '
$objEmail. to = $s _toaddress
Local $i _error = 0
Local $i _error_desciption = ""
If $s _ccaddress <> "" Then $objEmail. Cc = $s _ccaddress
If $s _bccaddress <> "" Then $objEmail. Bcc = $s _bccaddress
$objEmail. Subject = $s _subject
If stringinstr ($as _body, "<") and Stringinstr ($as _body, ">") Then
$objEmail. HTMLBody = $as _body
Else
$objEmail. TextBody = $as _body & @CRLF
EndIf
If $s _attachfiles <> "" Then
Local $S _files2attach = Stringsplit ($s _attachfiles, ","), File-delimiter
For $x = 1 to $S _files2attach[0]
$S _files2attach[$x] = _pathfull ($S _files2attach[$x])
If fileexists ($S _files2attach[$x]) Then
$objEmail. AddAttachment ($S _files2attach[$x])
Else
$i _error_desciption = $i _error_desciption & @LF & ' File not found to attach: ' & $S _files2attach[$x]
SetError (1)
return 0
EndIf
Next
EndIf
$objEmail. Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
$objEmail. Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s _smtpserver
$objEmail. Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $IPPort
; Authenticated SMTP
If $s _username <> "" Then
$objEmail. Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
$objEmail. Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s _username
$objEmail. Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s _password
EndIf
If $ssl Then
$objEmail. Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
EndIf
; Update settings
$objEmail. Configuration.Fields.Update
; Sent the message
$objEmail. Send
If @error Then
SetError (2)
return $oMyRet [1]
EndIf
Endfunc; ==>_inetsmtpmailcom.
; Com Error Handler
Func Myerrfunc ()
$HexHexNumber = Hex ($oMyError. Number, 8)
$oMyRet [0] = $HexNumber
$oMyRet [1] = STRINGSTRIPWS ($oMyError. Description, 3)
Consolewrite ("### COM Error!") Number: "& $HexNumber &" Scriptline: "& $oMyError. Scriptline &" Description: "& $oMyRet [1] & @ LF)
SetError (1); Something to check as this function returns
Return
Endfunc; ==>myerrfunc.
; Send Message End ====================================================================

; Organize the Memory
Func _reducememory ()
$I _pid = @AutoItPID
Local $ai _handle = Dllcall ("kernel32.dll", ' int ', ' openprocess ', ' int ', 0X1F0FFF, ' int ', False, ' int ', $I _pid)
Local $ai _return = Dllcall ("Psapi.dll", ' int ', ' emptyworkingset ', ' long ', $ai _handle[0])
Dllcall (' kernel32.dll ', ' int ', ' closehandle ', ' int ', $ai _handle[0])
Return $ai _return[0]
Endfunc; ==>_reducememory.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.