Script for obtaining the Internet IP address and sending it to the specified mailbox

Source: Internet
Author: User

Script house compiled exe files, convenient for you to directly use the http://www.jb51.net/softs/44627.html

The configuration file is as follows:Copy codeThe Code is as follows: the configuration file code
[Recipient]
Recipient address =
Email Title =
[Sender]
Email =
Password =

Core code:Copy codeThe Code is as follows: # region AutoIt3Wrapper precompiled parameters (common parameters)
# AutoIt3Wrapper_Icon = D: \ ico \ 3444 \ 2222.ico; icon, support for EXE, DLL, ICO
Export autoit3wrapper_outfile1_getip_sendmail.exe; output file name
# AutoIt3Wrapper_OutFile_Type = exe; file type
# AutoIt3Wrapper_Compression = 4; compression grade
# AutoIt3Wrapper_UseUpx = y; Use Compression
# AutoIt3Wrapper_Res_Comment =; Comment
# AutoIt3Wrapper_Res_Description =; details
# AutoIt3Wrapper_Res_Fileversion =; file version
# AutoIt3Wrapper_Res_FileVersion_AutoIncrement = p; automatically update the version
# AutoIt3Wrapper_Res_LegalCopyright =; Copyright
# AutoIt3Wrapper_Change2CUI = N; change the output program to CUI (console Program)
; # AutoItAutoIt3Wrapper_Res_Field = AutoIt Version | % AutoItVer %; Custom Resource segment
; # AutoIt3Wrapper_Run_Tidy =; script sorting
; # AutoIt3Wrapper_Run_Obfuscator =; code obfuscation
; # AutoIt3Wrapper_Run_AU3Check =; syntax check
; # AutoIt3Wrapper_Run_Before =; before running
; # AutoIt3Wrapper_Run_After =; after running
# Endregion AutoIt3Wrapper pre-compiled parameters (common parameters)
# Include <file. au3>
# Include <Inet. au3>
# Include <Date. au3>
; Repeat is prohibited.
$ G_szVersion = 'get the Internet IP address and send it to the specified mailbox'
If WinExists ($ g_szVersion) Then
Exit
EndIf
AutoItWinSetTitle ($ g_szVersion)

; Tray event
Opt ("TrayOnEventMode", 1); pallet Event Notification
Opt ("TrayMenuMode", 1); the default menu item (Script Paused/exited) (Script Paused/Exit) will not be displayed.
TrayCreateItem ("send ")
TrayItemSetOnEvent (-1, '_ sendmail ')
$ Exititem = TrayCreateItem ("Exit program ")
TrayItemSetOnEvent ($ exititem, "_ Exit ")
TraySetClick (16); The tray menu is displayed only when you click the second mouse button (right-click by default ).
TraySetToolTip ('get the Internet IP address and send it to the specified mail ')
TraySetState ()

Global $ testIp
Global $ oMyRet [2]
Global $ oMyError = ObjEvent ("AutoIt. Error", "MyErrFunc ")

$ S_ToAddress = IniRead (@ ScriptDir & "\ Config. ini", 'recipient ', 'recipient address','-1'); recipient address
$ S_Subject = IniRead (@ ScriptDir & "\ Config. ini", 'recipient ', 'mail title','-1'); mail title
TrayTip ("ready", "recipient address:" & $ s_ToAddress _
& @ CRLF & "email title:" & $ s_Subject, 5, 1)

_ Sendmail (); send an email

AdlibRegister ('_ Your cememory', 1000*10); sorts the memory every 10 seconds.

AdlibRegister ('_ sendmail', 1000*15)

While 1
Sleep (3000)
WEnd

Func _ Exit ()
Exit
EndFunc ;==> _ Exit

; Send email ====================================================== ====================================
Func _ Sendmail ()
$ S_SmtpServer = "smtp.163.com"; SMTP Server
$ S_FromName = "bbs.wglm.net"; email recipient
$ S_FromAddress = IniRead (@ ScriptDir & "\ Config. ini", 'sender ', 'mailbox', '-1'); mail sender address
$ S_ToAddress = IniRead (@ ScriptDir & "\ Config. ini", 'recipient ', 'recipient address','-1'); "19377708@qq.com"; recipient address
$ S_Subject = IniRead (@ ScriptDir & "\ Config. ini", 'recipient ', 'email title','-1'); "AU3 mail sending test"; mail title
Do
$ Getip = _ GetIP (); Internet IP Address
Sleep (300)
TrayTip ("prompt", 'Getting Internet IP address', 5, 1)
Until $ Getip <>-1

If $ testIp = $ Getip Then
TrayTip ("prompt", the 'Internet IP address is the same as the one sent last '& @ CRLF &' program will not repeatedly send. ', 5, 1)
Return; MsgBox (0, '', $ Getip)
EndIf
$ TestIp = $ Getip
$ As_Body = "Internet IP:" & $ Getip & @ CRLF & "sending time:" & _ NowDate () & "& _ NowTime (); mail body; get Internet IP Address
$ S_AttachFiles = ""; attachment address
$ S_CcAddress = ""; CC address
$ S_BccAddress = ""; BCC address
$ S_Username = IniRead (@ ScriptDir & "\ Config. ini", 'sender ', 'mailbox', '-1'); User Name
$ S_Password = IniRead (@ ScriptDir & "\ Config. ini", 'sender ', 'Password','-1'); Password
$ IPPort = 25; sending port. The sending port used by Gmail is 465.
$ Ssl = 0
$ Rc = _ response ($ 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", "error code for failed email sending:" & @ error & "Description:" & $ rc)
TrayTip ("failed to send email", "error code:" & @ error _
& @ CRLF & "Description:" & $ rc, 5, 1)
Else
_ FileWriteLog (@ ScriptDir & "\ MailSendlog. log "," successful email recipient address: "& $ s_ToAddress &" email title: "& $ s_Subject &" email body: "& $ as_Body)
TrayTip ("email sent successfully", "recipient address:" & $ s_ToAddress _
& @ CRLF & "mail title:" & $ s_Subject _
& @ CRLF & "email body:" & $ as_Body, 5, 1)
EndIf

EndFunc ;==> _ Sendmail

Func _ INetSmtpMailCom ($ s_SmtpServer, $ s_FromName, $ s_FromAddress, $ s_ToAddress, $ s_Subject = "", $ as_Body = "", $ s_AttachFiles = "", $ s_CcAddress = "", $ s_BccAddress = "", $ s_Username = "", $ s_Password = "", $ IPPort = 25, $ 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 for when this function returns
Return
EndFunc ;==> MyErrFunc
; Email sending end ==================================================== ====================================

; Sort 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 ;==> _ Your cememory

Related Article

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.