08-11
31
动态IP地址监控器
动态监控公网IP地址变化并邮件通知

程序下载:IPMon.zip
源代码:
IPMon.au3
查看代码 AUTOIT
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 | #Region ;**** 参数创建于 ACNWrapper_GUI **** #AutoIt3Wrapper_icon=5.ico #AutoIt3Wrapper_outfile=IPMon.exe #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_UseX64=n #AutoIt3Wrapper_Res_Comment=动态IP地址监控器 #AutoIt3Wrapper_Res_Description=动态IP地址监控器 #AutoIt3Wrapper_Res_Fileversion=2.3.11.823 #AutoIt3Wrapper_Res_LegalCopyright=╃苍狼山庄╃ #AutoIt3Wrapper_Res_Field=作者|Clang #AutoIt3Wrapper_Res_Field=网站|http://www.clang.cn #EndRegion ;**** 参数创建于 ACNWrapper_GUI **** #cs ____________________________________ AutoIt 版本: 3.3.5.6 脚本作者: Clang Email: admin@clnag.cn QQ/TM: 4370001 脚本版本: 监控ADSL动态IP地址 脚本功能: 监控ADSL动态IP地址 #ce _______________脚本开始_________________ #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GuiStatusBar.au3> #include <Constants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <SmtpMailer.au3> Opt("GUIOnEventMode", 1) Opt("GUICloseOnESC",0) Opt("TrayMenuMode",1) ;托盘内容要 Opt("TrayOnEventMode", 1) ;托盘转换成事务模式 Opt("TrayAutoPause", 0) ;把系统自动的单击暂停去掉 TrayTip("", "正在启动监控程序,请稍候...", 5) TraySetClick ( 16 ) ;仅允许点右键时出托盘菜单 Global Const $CrVer = "2.3.11.0823" Global Const $strName = "动态IP地址监控程序" Global $strPorgameName = $strName & " v" & $CrVer If WinExists($strPorgameName) Then _WinRestore() Exit ; 此脚本已经运行了 EndIf AutoItWinSetTitle($strPorgameName) Global Const $strConfigINI=@ScriptDir&"\IPMonConfig.ini" ;配置加上绝对路径较可靠,不加则是相对即时的“当前工作路径”,可能会导致找都找不到文件 Global $LogFile=@ScriptDir & "\Log\"& "log_" & @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC & ".log" Global $Button[3],$Checkbox[4],$strInIP,$strTime,$srtFile Global $str_EncryptPassword = "P@ss" ;$sdfsdf = _StringEncryptX(1, "s13936660688", $str_EncryptPassword, 2) ;MsgBox(0,"",$sdfsdf) ;ClipPut ( $sdfsdf ) Global $sendCount = 0 ;发送计数 Global $s_SmtpServer,$s_FromName,$s_FromAddress,$s_ToAddress,$s_Subject,$as_Body,$s_AttachFiles,$s_CcAddress,$s_BccAddress,$s_Username,$s_Password,$IPPort,$ssl Global Const $sInfoSource = "ip138" Global $SetAutoStart=IniRead($strConfigINI,"Config","AutoStart","") Global $SetAutoMon=IniRead($strConfigINI,"Config","AutoMon","") Global $SetCloseToMin=IniRead($strConfigINI,"Config","CloseToMin","") Global $SetStartToMin=IniRead($strConfigINI,"Config","StartToMin","") Global $SetiTime = IniRead($strConfigINI, "Config", "iTime", "") Global $SetFromAddress = IniRead($strConfigINI, "MailConfig", "FromAddress", "") Global $SetSmtpServer = IniRead($strConfigINI, "MailConfig", "SmtpServer", "") Global $SetUsername = IniRead($strConfigINI, "MailConfig", "Username", "") Global $SetPassword = IniRead($strConfigINI, "MailConfig", "Password", "") Global $SetToAddress = IniRead($strConfigINI, "MailConfig", "ToAddress", "") Global $SetIPPort = IniRead($strConfigINI, "MailConfig", "IPPort", "") Global $SetSubject = IniRead($strConfigINI, "MailConfig", "Subject", "") Global $s_FromName = "" ;邮件发送人 Global $s_AttachFiles = "" ;附件地址 Global $s_CcAddress = "" ;抄送地址 Global $s_BccAddress = "" ;密件抄送地址 Global $ssl = 0 #Region ### START Koda GUI section ### Form=d:\clang\desktop\ip监控\form1.kxf $Form1 = GUICreate($strPorgameName, 490, 433, (@DesktopWidth - 490) / 2, (@DesktopHeight - 433) / 2, BitOR($WS_SYSMENU,$WS_MINIMIZEBOX,$WS_CAPTION,$WS_POPUP,$WS_POPUPWINDOW,$WS_BORDER,$WS_CLIPSIBLINGS)) $Group1 = GUICtrlCreateGroup("当前IP", 16, 16, 241, 105) $Label12 = GUICtrlCreateLabel("内网IP地址:", 24, 40, 74, 17) $strInsideIP = GUICtrlCreateLabel("", 112, 32, 130, 49) $Label9 = GUICtrlCreateLabel("当前公网IP地址:", 24, 96, 98, 17) $strInternetIP = GUICtrlCreateLabel("", 128, 96, 100, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group2 = GUICtrlCreateGroup("邮件发送设置", 16, 136, 457, 225) $Label1 = GUICtrlCreateLabel("发邮件人邮箱:", 32, 160, 88, 17) $inputFromAddress = GUICtrlCreateInput("", 128, 160, 329, 21) GUICtrlSetData ( $inputFromAddress, $SetFromAddress ) $Label2 = GUICtrlCreateLabel("SMTP地址:", 32, 192, 70, 17) $inputSmtpServer = GUICtrlCreateInput("", 128, 192, 193, 21) GUICtrlSetData ( $inputSmtpServer, $SetSmtpServer ) $Label8 = GUICtrlCreateLabel("端口:", 336, 192, 40, 17) $inputIPPort = GUICtrlCreateInput("", 384, 192, 73, 21) GUICtrlSetData ( $inputIPPort, $SetIPPort ) $Label3 = GUICtrlCreateLabel("发件箱用户名:", 32, 224, 88, 17) $inputUsername = GUICtrlCreateInput("", 128, 224, 329, 21) GUICtrlSetData ( $inputUsername, $SetUsername ) $Label4 = GUICtrlCreateLabel("发件箱密码:", 32, 256, 76, 17) $inputPassword = GUICtrlCreateInput("", 128, 256, 329, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD)) GUICtrlSetData ( $inputPassword, $SetPassword ) $Label5 = GUICtrlCreateLabel("收件箱地址:", 32, 288, 76, 17) $inputToAddress = GUICtrlCreateInput("", 128, 288, 329, 21) GUICtrlSetData ( $inputToAddress, $SetToAddress ) $Label11 = GUICtrlCreateLabel("邮件主题:", 32, 320, 64, 17) $inputSubject = GUICtrlCreateInput("", 128, 320, 329, 21) GUICtrlSetData ( $inputSubject, $SetSubject ) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group3 = GUICtrlCreateGroup("参数设置", 272, 16, 201, 105) $Checkbox[0] = GUICtrlCreateCheckbox("随系统启动", 280, 40, 89, 17) If $SetAutoStart="1" Then GUICtrlSetState($Checkbox[0],$GUI_CHECKED) Else GUICtrlSetState($Checkbox[0], $GUI_UNCHECKED) EndIf $Checkbox[1] = GUICtrlCreateCheckbox("开始监控", 376, 40, 89, 17) If $SetAutoMon="1" Then GUICtrlSetState($Checkbox[1],$GUI_CHECKED) Else GUICtrlSetState($Checkbox[1], $GUI_UNCHECKED) EndIf $Checkbox[2] = GUICtrlCreateCheckbox("启动后最小化", 280, 64, 89, 17) If $SetStartToMin="1" Then GUICtrlSetState($Checkbox[2],$GUI_CHECKED) Else GUICtrlSetState($Checkbox[2], $GUI_UNCHECKED) EndIf $Checkbox[3] = GUICtrlCreateCheckbox("关闭最小化", 376, 64, 81, 17) If $SetCloseToMin="1" Then GUICtrlSetState($Checkbox[3],$GUI_CHECKED) Else GUICtrlSetState($Checkbox[3], $GUI_UNCHECKED) EndIf $Label6 = GUICtrlCreateLabel("监控时间间隔", 288, 96, 76, 17) $inputTime = GUICtrlCreateInput("", 368, 92, 49, 21) If $SetiTime <> "" Then GUICtrlSetData ( $inputTime, $SetiTime ) Else GUICtrlSetData ( $inputTime, "5" ) EndIf $Label7 = GUICtrlCreateLabel("分钟", 424, 96, 28, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $Button[0] = GUICtrlCreateButton("发送测试", 216, 376, 75, 25) $Button[1] = GUICtrlCreateButton("清空设置", 304, 376, 75, 25) $Button[2] = GUICtrlCreateButton("保存设置", 392, 376, 75, 25) $StatusBar1 = _GUICtrlStatusBar_Create($Form1) Dim $StatusBar1_PartsWidth[2] = [280, -1] _GUICtrlStatusBar_SetParts($StatusBar1, $StatusBar1_PartsWidth) _GUICtrlStatusBar_SetText($StatusBar1, "", 0) _GUICtrlStatusBar_SetText($StatusBar1, @TAB & @TAB & "╃苍狼山庄╃ http://www.clang.cn", 1) ;======托盘菜单区====== $TrayShow = TrayCreateItem("显示主界面") TrayItemSetOnEvent($TrayShow,"_ShowMain") TrayItemSetState ( $TrayShow, $TRAY_UNCHECKED) TrayCreateItem("") $TrayExit = TrayCreateItem("退出") TrayItemSetOnEvent(-1,"_Quit") TraySetOnEvent($TRAY_EVENT_PRIMARYDOUBLE,"_ShowMain") ;左键双击通知区域 TraySetState() TrayTip("", "", 5) TraySetToolTip($strName) $info =_NetworkAdapterInfo() $InsideIPCount = $info[0][0] For $i = 1 to $info[0][0] Step +1 $strIP = "IP[" & $i & "]:" & $info[$i][5] If $strInIP = "" Then $strInIP = $strIP Else $strInIP = $strInIP & @CRLF & $strIP EndIf Next $asResult = fn_GetWanIP($sInfoSource) If Not IsArray($asResult) Then GUICtrlSetData ( $strInternetIP, "unknown ip" ) Else GUICtrlSetData ( $strInternetIP, $asResult[0] ) EndIf GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### If GUICtrlRead($Checkbox[3])=1 Then GUISetOnEvent($GUI_EVENT_CLOSE, "_WinMinimize") Else GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit") EndIf If GUICtrlRead($Checkbox[2])=1 Then _WinMinimize() EndIf GUISetOnEvent($GUI_EVENT_MINIMIZE, "_WinMinimize") For $i=0 To 2 GUICtrlSetOnEvent($Button[$i], "_btnEvent") Next For $i=0 To 3 GUICtrlSetOnEvent($Checkbox[$i], "_cbEvent") Next ;======释放内存====== _ReduceMemory(@AutoItPID) _FirstRun() While 1 $oldIP = GUICtrlRead( $strInternetIP ) $asResult = fn_GetWanIP($sInfoSource) If Not IsArray($asResult) Then GUICtrlSetData ( $strInternetIP, "unknown ip" ) Else GUICtrlSetData ( $strInternetIP, $asResult[0] ) EndIf ;MsgBox (0,"",$strInIP ) GUICtrlSetData ( $strInsideIP, $strInIP ) If GUICtrlRead($Checkbox[1])=1 Then $result = StringCompare($oldIP, GUICtrlRead( $strInternetIP )) $strTime = @YEAR & "年" & @MON & "月" & @MDAY & "日" & @HOUR & "时" & @MIN & "分" & @SEC & "秒" If $result <> 0 Then $s_FromAddress = IniRead($strConfigINI, "MailConfig", "FromAddress", "") $s_SmtpServer = IniRead($strConfigINI, "MailConfig", "SmtpServer", "") $s_Username = IniRead($strConfigINI, "MailConfig", "Username", "") $s_Password = _StringEncryptX(0, IniRead($strConfigINI, "MailConfig", "Password", ""), $str_EncryptPassword, 2) $s_ToAddress = IniRead($strConfigINI, "MailConfig", "ToAddress", "") $IPPort = IniRead($strConfigINI, "MailConfig", "IPPort", "") $s_Subject = IniRead($strConfigINI, "MailConfig", "Subject", "") & "-" & $strTime $as_Body = "来自计算机【" & @ComputerName & "】" & @CRLF & "用户【" & @UserName & "】" & @CRLF & "获得内网IP地址" & $InsideIPCount & "个:" & @CRLF & GUICtrlRead( $strInsideIP ) & @CRLF & "公网IP:" & GUICtrlRead( $strInternetIP ) _sendmailFunc() $sendCount = $sendCount + 1 EndIf EndIf _TraySetToolTip() $SetiTime = IniRead($strConfigINI, "Config", "iTime", "") If $SetiTime = "" Then $SetiTime = "5" EndIf _ReduceMemory(@AutoItPID) Sleep( $SetiTime * 60000 ) ;MsgBox(0,"","t") WEnd Func _FirstRun() GUICtrlSetData ( $strInsideIP, $strInIP ) If GUICtrlRead($Checkbox[1])=1 Then $s_FromAddress = IniRead($strConfigINI, "MailConfig", "FromAddress", "") $s_SmtpServer = IniRead($strConfigINI, "MailConfig", "SmtpServer", "") $s_Username = IniRead($strConfigINI, "MailConfig", "Username", "") $s_Password = _StringEncryptX(0, IniRead($strConfigINI, "MailConfig", "Password", ""), $str_EncryptPassword, 2) $s_ToAddress = IniRead($strConfigINI, "MailConfig", "ToAddress", "") $IPPort = IniRead($strConfigINI, "MailConfig", "IPPort", "") $strTime = @YEAR & "年" & @MON & "月" & @MDAY & "日" & @HOUR & "时" & @MIN & "分" & @SEC & "秒" $s_Subject = IniRead($strConfigINI, "MailConfig", "Subject", "") & "-" & $strTime $as_Body = "来自计算机【" & @ComputerName & "】" & @CRLF & "用户【" & @UserName & "】" & @CRLF & "获得内网IP地址" & $InsideIPCount & "个:" & @CRLF & GUICtrlRead( $strInsideIP ) & @CRLF & "公网IP:" & GUICtrlRead( $strInternetIP ) _sendmailFunc() $sendCount = $sendCount + 1 EndIf _TraySetToolTip() _ReduceMemory(@AutoItPID) EndFunc ;======事件函数====== Func _btnEvent() Switch @GUI_CtrlId Case $Button[0] $s_FromAddress = IniRead($strConfigINI, "MailConfig", "FromAddress", "") $s_SmtpServer = IniRead($strConfigINI, "MailConfig", "SmtpServer", "") $s_Username = IniRead($strConfigINI, "MailConfig", "Username", "") $s_Password = _StringEncryptX(0, IniRead($strConfigINI, "MailConfig", "Password", ""), $str_EncryptPassword, 2) $s_ToAddress = IniRead($strConfigINI, "MailConfig", "ToAddress", "") $IPPort = IniRead($strConfigINI, "MailConfig", "IPPort", "") $strTime = @YEAR & "年" & @MON & "月" & @MDAY & "日" & @HOUR & "时" & @MIN & "分" & @SEC & "秒" $s_Subject = IniRead($strConfigINI, "MailConfig", "Subject", "") & "-" & $strTime $as_Body = "来自计算机【" & @ComputerName & "】" & @CRLF & "用户【" & @UserName & "】" & @CRLF & "获得内网IP地址:" & $InsideIPCount & "个" & @CRLF & GUICtrlRead( $strInsideIP ) & @CRLF & "公网IP:" & GUICtrlRead( $strInternetIP ) ;MsgBox(0,"",$as_Body) _sendmailFunc() $sendCount = $sendCount + 1 _TraySetToolTip() Case $Button[1] IniWrite($strConfigINI, "MailConfig", "FromAddress", "") IniWrite($strConfigINI, "MailConfig", "SmtpServer", "") IniWrite($strConfigINI, "MailConfig", "Username", "") IniWrite($strConfigINI, "MailConfig", "Password", "") IniWrite($strConfigINI, "MailConfig", "ToAddress", "") IniWrite($strConfigINI, "MailConfig", "IPPort", "") IniWrite($strConfigINI, "MailConfig", "Subject", "") IniWrite($strConfigINI, "Config", "iTime", "") GUICtrlSetData ( $inputFromAddress, "" ) GUICtrlSetData ( $inputSmtpServer, "" ) GUICtrlSetData ( $inputIPPort, "" ) GUICtrlSetData ( $inputUsername, "" ) GUICtrlSetData ( $inputPassword, "" ) GUICtrlSetData ( $inputToAddress, "" ) GUICtrlSetData ( $inputSubject, "" ) GUICtrlSetData ( $inputTime, "" ) IniWrite($strConfigINI,"Config","AutoStart","0") RegDelete("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run","IPMon_C") IniWrite($strConfigINI,"Config","AutoMon","0") IniWrite($strConfigINI,"Config","StartToMin","0") IniWrite($strConfigINI,"Config","CloseToMin","0") Case $Button[2] IniWrite($strConfigINI, "MailConfig", "FromAddress", GUICtrlRead( $inputFromAddress )) IniWrite($strConfigINI, "MailConfig", "SmtpServer", GUICtrlRead( $inputSmtpServer )) IniWrite($strConfigINI, "MailConfig", "Username", GUICtrlRead( $inputUsername )) If $SetPassword <> GUICtrlRead( $inputPassword ) Then IniWrite($strConfigINI, "MailConfig", "Password", _StringEncryptX(1, GUICtrlRead( $inputPassword ), $str_EncryptPassword, 2)) Else IniWrite($strConfigINI, "MailConfig", "Password",GUICtrlRead( $inputPassword )) EndIf IniWrite($strConfigINI, "MailConfig", "ToAddress", GUICtrlRead( $inputToAddress )) IniWrite($strConfigINI, "MailConfig", "IPPort", GUICtrlRead( $inputIPPort )) IniWrite($strConfigINI, "MailConfig", "Subject", GUICtrlRead( $inputSubject )) IniWrite($strConfigINI, "Config", "iTime", GUICtrlRead( $inputTime )) EndSwitch EndFunc Func _cbEvent() Switch @GUI_CtrlId Case $Checkbox[0] If GUICtrlRead($Checkbox[0])=1 Then IniWrite($strConfigINI,"Config","AutoStart","1") RegWrite("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run","IPMon_C","REG_SZ",@ScriptFullPath) If RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run","IPMon_C") <> @ScriptFullPath Then GUICtrlSetState($Checkbox[0],$GUI_UNCHECKED) IniWrite($strConfigINI,"Config","AutoStart","0") EndIf Else IniWrite($strConfigINI,"Config","AutoStart","0") RegDelete("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run","IPMon_C") EndIf Case $Checkbox[1] If GUICtrlRead($Checkbox[1])=1 Then IniWrite($strConfigINI,"Config","AutoMon","1") _FirstRun() TraySetToolTip("正在监控 - 已发送邮件" & $sendCount & "次." & @CRLF & "最后一次监控时间:" & $strTime) _GUICtrlStatusBar_SetText($StatusBar1, "最后监控时间:" & $strTime, 0) Else IniWrite($strConfigINI,"Config","AutoMon","0") TraySetToolTip("停止监控 - 已发送邮件" & $sendCount & "次。" & @CRLF & "最后一次监控时间:" & $strTime) _GUICtrlStatusBar_SetText($StatusBar1, "最后监控时间:" & $strTime, 0) EndIf Case $Checkbox[2] If GUICtrlRead($Checkbox[2])=1 Then IniWrite($strConfigINI,"Config","StartToMin","1") Else IniWrite($strConfigINI,"Config","StartToMin","0") EndIf Case $Checkbox[3] If GUICtrlRead($Checkbox[3])=1 Then GUISetOnEvent($GUI_EVENT_CLOSE, "_WinMinimize") IniWrite($strConfigINI,"Config","CloseToMin","1") Else GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit") IniWrite($strConfigINI,"Config","CloseToMin","0") EndIf EndSwitch EndFunc Func _TraySetToolTip() If GUICtrlRead($Checkbox[1])=1 Then TraySetToolTip("正在监控 - 已发送邮件" & $sendCount & "次。" & @CRLF & "最后一次监控时间:" & $strTime) _GUICtrlStatusBar_SetText($StatusBar1, "最后监控时间:" & $strTime, 0) Else TraySetToolTip("停止监控 - 已发送邮件" & $sendCount & "次。" & @CRLF & "最后一次监控时间:" & $strTime) _GUICtrlStatusBar_SetText($StatusBar1, "最后监控时间:" & $strTime, 0) EndIf EndFunc Func _sendmailFunc() If GUICtrlRead( $inputFromAddress ) <> "" And GUICtrlRead( $inputSmtpServer ) <> "" And GUICtrlRead( $inputUsername ) <> "" And GUICtrlRead( $inputPassword ) <> "" And GUICtrlRead( $inputToAddress ) <> "" And GUICtrlRead( $inputIPPort ) <> "" And GUICtrlRead( $inputSubject ) <> "" Then sendmail () Else MsgBox(0+16+262144, $strName, "未配置“邮件发送设置”!") EndIf EndFunc ;======最小化====== Func _WinMinimize() ;窗口最小化隐藏操作 TrayTip("提示","监控正在运行,双击此图标显示监视界面!",10,1) GUISetState(@SW_HIDE) _ReduceMemory(@AutoItPID) ;~ AdlibEnable("DSTask", 1000) EndFunc ;======恢复====== Func _WinRestore() ;窗口恢复还原操作 TrayItemSetState ( $TrayShow, $TRAY_UNCHECKED) GUISetState(@SW_SHOW) GUISetState(@SW_RESTORE) if WinActive($strPorgameName)=0 Then WinActivate($strPorgameName) _ReduceMemory(@AutoItPID) EndFunc ;==> kcWinRestore ;======显示主界面====== Func _ShowMain() _WinRestore() EndFunc ;======退出====== Func _Quit() Exit EndFunc ;======邮件发送====== Func sendmail() Global $oMyRet[2] Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") $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 ;MsgBox(0+16+262144, $strName, "邮件发送失败,错误代号:" & @error & @CRLF & "描述:" & $rc) _Log(@error,$rc) EndIf EndFunc ;==>sendmail ;======日志记录====== Func _Log($strErr,$strDes) $srtFile = FileOpen($LogFile, 10) FileWrite($srtFile,"On " & @YEAR & "年" & @MON & "月" & @MDAY & "日" & @HOUR & "时" & @MIN & "分" & @SEC & "秒" & @CRLF & "邮件发送失败,错误代号:" & $strErr & @CRLF & "描述:" & $strDes) FileClose($srtFile) EndFunc ;======内存释放====== Func _ReduceMemory($i_PID = -1);内存释放函数 该函数抄自ACN论坛(http://autoit.net.cn) If $i_PID <> -1 Then 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]) Else Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1) EndIf Return $ai_Return[0] EndFunc ;==>_ReduceMemory ;======密码加密====== Func _StringEncryptX($i_Encrypt, $s_EncryptText, $s_EncryptPassword, $i_EncryptLevel = 1) If $i_Encrypt <> 0 And $i_Encrypt <> 1 Then SetError(1) Return '' ElseIf $s_EncryptText = '' Or $s_EncryptPassword = '' Then SetError(1) Return '' Else If Number($i_EncryptLevel) <= 0 Or Int($i_EncryptLevel) <> $i_EncryptLevel Then $i_EncryptLevel = 1 Local $v_EncryptModified, $i_EncryptCountH, $i_EncryptCountG, $v_EncryptSwap, $av_EncryptBox[256][2] Local $i_EncryptCountA, $i_EncryptCountB, $i_EncryptCountC, $i_EncryptCountD, $i_EncryptCountE Local $v_EncryptCipher, $v_EncryptCipherBy If $i_Encrypt = 1 Then For $i_EncryptCountF = 0 To $i_EncryptLevel Step 1 $i_EncryptCountG = '' $i_EncryptCountH = '' $v_EncryptModified = '' For $i_EncryptCountG = 1 To StringLen($s_EncryptText) If $i_EncryptCountH = StringLen($s_EncryptPassword) Then $i_EncryptCountH = 1 Else $i_EncryptCountH += 1 EndIf $v_EncryptModified = $v_EncryptModified & ChrW(BitXOR(AscW(StringMid($s_EncryptText, $i_EncryptCountG, 1)), AscW(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255)) Next $s_EncryptText = $v_EncryptModified $i_EncryptCountA = '' $i_EncryptCountB = 0 $i_EncryptCountC = '' $i_EncryptCountD = '' $i_EncryptCountE = '' $v_EncryptCipherBy = '' $v_EncryptCipher = '' $v_EncryptSwap = '' $av_EncryptBox = '' Local $av_EncryptBox[256][2] For $i_EncryptCountA = 0 To 255 $av_EncryptBox[$i_EncryptCountA][1] = AscW(StringMid($s_EncryptPassword, Mod($i_EncryptCountA, StringLen($s_EncryptPassword)) + 1, 1)) $av_EncryptBox[$i_EncryptCountA][0] = $i_EncryptCountA Next For $i_EncryptCountA = 0 To 255 $i_EncryptCountB = Mod(($i_EncryptCountB + $av_EncryptBox[$i_EncryptCountA][0] + $av_EncryptBox[$i_EncryptCountA][1]), 256) $v_EncryptSwap = $av_EncryptBox[$i_EncryptCountA][0] $av_EncryptBox[$i_EncryptCountA][0] = $av_EncryptBox[$i_EncryptCountB][0] $av_EncryptBox[$i_EncryptCountB][0] = $v_EncryptSwap Next For $i_EncryptCountA = 1 To StringLen($s_EncryptText) $i_EncryptCountC = Mod(($i_EncryptCountC + 1), 256) $i_EncryptCountD = Mod(($i_EncryptCountD + $av_EncryptBox[$i_EncryptCountC][0]), 256) $i_EncryptCountE = $av_EncryptBox[Mod(($av_EncryptBox[$i_EncryptCountC][0] + $av_EncryptBox[$i_EncryptCountD][0]), 256)][0] $v_EncryptCipherBy = BitXOR(AscW(StringMid($s_EncryptText, $i_EncryptCountA, 1)), $i_EncryptCountE) $v_EncryptCipher &= Hex($v_EncryptCipherBy, 2) Next $s_EncryptText = $v_EncryptCipher Next Else For $i_EncryptCountF = 0 To $i_EncryptLevel Step 1 $i_EncryptCountB = 0 $i_EncryptCountC = '' $i_EncryptCountD = '' $i_EncryptCountE = '' $v_EncryptCipherBy = '' $v_EncryptCipher = '' $v_EncryptSwap = '' $av_EncryptBox = '' Local $av_EncryptBox[256][2] For $i_EncryptCountA = 0 To 255 $av_EncryptBox[$i_EncryptCountA][1] = AscW(StringMid($s_EncryptPassword, Mod($i_EncryptCountA, StringLen($s_EncryptPassword)) + 1, 1)) $av_EncryptBox[$i_EncryptCountA][0] = $i_EncryptCountA Next For $i_EncryptCountA = 0 To 255 $i_EncryptCountB = Mod(($i_EncryptCountB + $av_EncryptBox[$i_EncryptCountA][0] + $av_EncryptBox[$i_EncryptCountA][1]), 256) $v_EncryptSwap = $av_EncryptBox[$i_EncryptCountA][0] $av_EncryptBox[$i_EncryptCountA][0] = $av_EncryptBox[$i_EncryptCountB][0] $av_EncryptBox[$i_EncryptCountB][0] = $v_EncryptSwap Next For $i_EncryptCountA = 1 To StringLen($s_EncryptText) Step 2 $i_EncryptCountC = Mod(($i_EncryptCountC + 1), 256) $i_EncryptCountD = Mod(($i_EncryptCountD + $av_EncryptBox[$i_EncryptCountC][0]), 256) $i_EncryptCountE = $av_EncryptBox[Mod(($av_EncryptBox[$i_EncryptCountC][0] + $av_EncryptBox[$i_EncryptCountD][0]), 256)][0] $v_EncryptCipherBy = BitXOR(Dec(StringMid($s_EncryptText, $i_EncryptCountA, 2)), $i_EncryptCountE) $v_EncryptCipher = $v_EncryptCipher & ChrW($v_EncryptCipherBy) Next $s_EncryptText = $v_EncryptCipher $i_EncryptCountG = '' $i_EncryptCountH = '' $v_EncryptModified = '' For $i_EncryptCountG = 1 To StringLen($s_EncryptText) If $i_EncryptCountH = StringLen($s_EncryptPassword) Then $i_EncryptCountH = 1 Else $i_EncryptCountH += 1 EndIf $v_EncryptModified &= ChrW(BitXOR(AscW(StringMid($s_EncryptText, $i_EncryptCountG, 1)), AscW(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255)) Next $s_EncryptText = $v_EncryptModified Next EndIf Return $s_EncryptText EndIf EndFunc ;==>_StringEncryptX Func _NetworkAdapterInfo() ;====================================================== ; ; 函数名称: _NetworkAdapterInfo() ; 详细信息: 获取系统所有网卡信息 ; 返回值说明: ; 以二维数组方式返回.例如 $info=_NetworkAdapterInfo() ; $info[0][0] 网卡数量 ; $info[1][0] 第一块网卡的标志1 ; $info[1][1] 第一块网卡的状态 ; 状态说明:;Case 0 strConnStatus = "Disconnected" ;Case 1 strConnStatus = "Connecting" ;Case 1 strConnStatus = "connected" ;Case 3 strConnStatus = "Disconnecting" ;Case 4 strConnStatus = "Hardware not present" ;Case 5 strConnStatus = "Hardware disabled" ;Case 6 strConnStatus = "Hardware malfunction" ;Case 7 strConnStatus = "Media disconnected" ;Case 8 strConnStatus = "Authenticating" ;Case 9 strConnStatus = "Authentication succeeded" ;Case 10 strConnStatus = "Authentication failed" ;Case 11 strConnStatus = "Invalid address" ;Case 12 strConnStatus = "Connecting" ;Case Else strConnStatus = "Credentials required" ; $info[1][2] 第一块网卡的网卡名称 ; $info[1][3] 第一块网卡的连接名称 ; $info[1][4] 第一块网卡的MAC地址 ; $info[1][5] 第一块网卡的IP地址 ; $info[1][6] 第一块网卡的默认网关 ; $info[1][7] 第一块网卡的子网掩码 ; $info[1][8] 第一块网卡的主DNS ; $info[1][9] 第一块网卡的次DNS ; 第二块网卡: ; $info[2][0] 第二块网卡的标志1 ; $info[2][9] 第二块网卡的次DNS ; 其他网卡信息依次类推。。。 ; 注意,此UDF不会获取已经禁用的网卡。 ; 作者: Sanhen ([email]gxbeiliu@163.com[/email]) ; 网站: [url]www.lunhui.net.cn[/url] [url]www.autoit.net.cn[/url] ;====================================================== Local $colItem Local $objItem Local $colItems Local $objItems Local $objWMIService Local $Adapters[1][10] $Adapters[0][0] = 0 $objWMIService = ObjGet("winmgmts:\\localhost\root\CIMV2") $colItem = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter WHERE NetConnectionStatus = 2", "WQL", 0x30) If IsObj($colItem) Then For $objItem In $colItem If $objItem.MACAddress = "00:00:00:00:00:00" Then ContinueLoop $Adapters[0][0] += 1 ReDim $Adapters[UBound($Adapters) + 1][10] $Adapters[$Adapters[0][0]][0] += $Adapters[0][0] $Adapters[$Adapters[0][0]][1] = $objItem.NetConnectionStatus $Adapters[$Adapters[0][0]][2] = $objItem.Description $Adapters[$Adapters[0][0]][3] = $objItem.NetConnectionID $Adapters[$Adapters[0][0]][4] = $objItem.MACAddress $colItems = $objWMIService.ExecQuery('SELECT * FROM Win32_NetworkAdapterConfiguration WHERE MACAddress = "'&$Adapters[$Adapters[0][0]][4]&'" And IPEnabled != 0 ' , "WQL", 0x30) If IsObj($colItems) Then For $objItems In $colItems ;if $objItem1.IPAddress(0) = "0.0.0.0" Then ContinueLoop $Adapters[$Adapters[0][0]][5] = $objItems.IPAddress(0) $Adapters[$Adapters[0][0]][6] = $objItems.DefaultIPGateway(0) $Adapters[$Adapters[0][0]][7] = $objItems.IPSubnet(0) $Adapters[$Adapters[0][0]][8] = $objItems.DNSServerSearchOrder(0) If UBound($objItems.DNSServerSearchOrder)=1 Then $Adapters[$Adapters[0][0]][9] = "0" Else $Adapters[$Adapters[0][0]][9] = $objItems.DNSServerSearchOrder(1) EndIf ;$Adapters[$Adapters[0][0]][9] = $objItems.DNSServerSearchOrder(1) ;$i=1 ;$dnsnum = UBound($objItems.DNSServerSearchOrder)-1 ;$dnss= "" ;MsgBox(0,"","网卡型号=" & $objItem.Description & @crlf & $dnsnum) ;For $i=0 To $dnsnum ; $dns = $objItems.DNSServerSearchOrder($i) ; $dnss = $dnss & $dns & "/" ; $Adapters[$Adapters[0][0]][8] = StringTrimRight($dnss, 1) ;Next Next EndIf Next EndIf Return $Adapters EndFunc ; =============================================================================================================================== ; 函数名称: fn_GetWanIP ; 函数环境: AutoIt3 v3.3.6.1 ; 函数版本: 1.1.0 Build 20110316 ; 函数说明: 跟据参数,选择从不同的信息渠道获取外网IP地址 ; 函数语法: fn_GetWanIP($sInfoSource, $sTempDir, $sTempFile) ; 参数说明: $sInfoSource —— 信息源标识/标号 ; |1 —— 信息源标号,选择信息源: http://www.ip138.com/ip2city.asp ; |2 —— 信息源标号,选择信息源: http://www.whatismyip.com/automation/n09230945.asp ; |3 —— 信息源标号,选择信息源: http://www.aamailsoft.com/getip.php ; |4 —— 信息源标号,选择信息源: http://checkip.dyndns.org/ ; |5 —— 信息源标号,选择信息源: http://www.geobytes.com/IpLocator.htm ; |6 —— (默认)信息源标号,选择信息源: http://ip.qq.com/cgi-bin/index ; |7 —— 信息源标号,选择信息源: http://www.123cha.com/ip/ ; |8 —— 信息源标号,选择信息源: http://ip.91cool.net/ip.php ; ; |ip138 —— 信息源标识,选择信息源: http://www.ip138.com/ip2city.asp ; |whatismyip —— 信息源标识,选择信息源: http://www.whatismyip.com/automation/n09230945.asp ; |aamailsoft —— 信息源标识,选择信息源: http://www.aamailsoft.com/getip.php ; |dyndns —— 信息源标识,选择信息源: http://checkip.dyndns.org/ ; |geobytes —— 信息源标识,选择信息源: http://www.geobytes.com/IpLocator.htm ; |qq —— 信息源标识,选择信息源: http://ip.qq.com/cgi-bin/index ; |123cha —— 信息源标识,选择信息源: http://www.123cha.com/ip/ ; |91cool —— 信息源标识,选择信息源: http://ip.91cool.net/ip.php ; ; $iMode —— 是否只使用指定的信息源获取IP地址(1 = yes|0(默认) = no) ; $sTempDir —— 参数已取消,保留此参数格式只为了兼容旧版本函数 ; $sTempFile —— 参数已取消,保留此参数格式只为了兼容旧版本函数 ; 返 回 值: 返回一个数组: ; 第一个元素($array[0])保存外网IP地址,获取失败返回 "0.0.0.0" ; 第二个元素($array[1])保存外网IP地址所在的物理地址,获取失败返回空字符 ; 第三个元素($array[2])保存信息来源地址,获取失败返回空字符 ; 函数作者: easefull ; 创建日期: 2009-12-31 ; 更新日期: 2011-03-16 ; 函数改良: ; 修改说明: ; 相关函数: ; 链接网页: ; 函数示例: ; Example 1: ; #include <Array.au3> ; $Array = fn_GetWanIP() ; _ArrayDisplay($Array) ; ; Example 2: ; #include <Array.au3> ; $iInfoSource = 1 ; $Array = fn_GetWanIP($iInfoSource) ; _ArrayDisplay($Array) ; ; Example 3: ; #include <Array.au3> ; $sInfoSource = "ip138" ; $Array = fn_GetWanIP($sInfoSource) ; _ArrayDisplay($Array) ; ; Example 4: ; #include <Array.au3> ; $iInfoSource = "ip138" ; $iMode = 1 ; $Array = fn_GetWanIP($iInfoSource, $iMode) ; _ArrayDisplay($Array) ; =============================================================================================================================== Func fn_GetWanIP($sInfoSource = 6, $iMode = 0, $sTempDir = "", $sTempFile = "") ;================================================= ; 定义局部变量 ; $sURL —— 储存 IP获取页面URL(Key) ; $asURL —— 储存 IP获取页面URL(数组) ; $asResult —— 储存 外网IP地址和物理地址 ; $nIndex —— 储存 可获取的信息源数量 ; $iStep —— 储存 信息标识累加器 ; $sHTML —— 储存 下载页面内容 ; $asIP[0] —— 中转变量 匹配的正则返回值 ;================================================= Local $sURL = @CR & _ "http://www.ip138.com/ip2city.asp" & @CR & _ "http://www.whatismyip.com/automation/n09230945.asp" & @CR & _ "http://www.aamailsoft.com/getip.php" & @CR & _ "http://checkip.dyndns.org/" & @CR & _ "http://www.geobytes.com/IpLocator.htm" & @CR & _ "http://ip.QQ.com/cgi-bin/index" & @CR & _ "http://www.123cha.com/ip/" & @CR & _ "http://ip.91cool.net/ip.php" & @CR Local $asURL = StringRegExp($sURL, '(?<=\r)[\S]+(?=\r)', 3) Local $nIndex = UBound($asURL), $iStep = 0, $iMark Local $asResult[3], $sHTML, $asIP[1] ;================================================= ; 检查参数,防止意外错误 ;================================================= ; 格式化参数 信息源标识 ;================================================= If StringIsDigit($sInfoSource) = 0 Or $sInfoSource > $nIndex Or $sInfoSource < 0 Then For $i = 0 To $nIndex - 1 Step 1 $asIP = StringRegExp($asURL[$i], '(?<=\.)\w+(?=\.)', 1) If $sInfoSource == $asIP[0] Then $sInfoSource = $i + 1 ExitLoop EndIf Next If StringIsDigit($sInfoSource) = 0 Or $sInfoSource > $nIndex Or $sInfoSource < 0 Then $sInfoSource = 6 EndIf ;================================================= ; 使用机械指针结构,从不同信息点循环获取IP信息 ;================================================= Do ;================================================= ; 从指定的信息源获取信息 ;================================================= $sHTML = BinaryToString(InetRead($asURL[$sInfoSource - 1], 1)) $asIP = StringRegExp($sHTML, '(((25[0-5]|2[0-4]\d|[01]?\d?\d)\.){3}(25[0-5]|2[0-4]\d|[01]?\d?\d))', 1) ;================================================= ; 如果成功获取信息 ;================================================= If Not @error Then ;================================================= ; 保存 IP地址 ;================================================= $asResult[0] = $asIP[0] ;================================================= ; 获取 信息来源地址 ;================================================= $asIP = StringRegExp($asURL[$sInfoSource - 1], '(?<=\.)\w+\.\w+(?=\/)', 1) If Not @error Then $asResult[2] = $asIP[0] ;================================================= ; 获取 IP所在的物理地址 ;================================================= If $sInfoSource <> 6 And $sInfoSource <> 8 Then ;================================================= ; 信息源不提供物理地址的将从第6信息源获取物理地址 ;================================================= $sInfoSource = 6 $sHTML = BinaryToString(InetRead($asURL[$sInfoSource - 1], 1)) EndIf Select Case $sInfoSource = 6 $asIP = StringRegExp($sHTML, '(?<=<span>)[^<]+(?=</span></p>)', 1) If Not @error Then $asResult[1] = StringRegExpReplace($asIP[0], ' ', '') Case $sInfoSource = 8 $asIP = StringRegExp($sHTML, '(?<=来自)[^"]+(?=")', 1) If Not @error Then $asResult[1] = $asIP[0] EndSelect EndIf ;================================================= ; 机械指针计算 ; 继续循环查找IP ;================================================= $iStep += 1 $sInfoSource = $sInfoSource + $iStep If $sInfoSource > $nIndex Then $sInfoSource -= $nIndex Until $asResult[0] Or $iMode Or $iStep = $nIndex ;================================================= ; 返回执行结果 ;================================================= If Not $asResult[0] Then $asResult[0] = "0.0.0.0" Return($asResult) EndFunc ;==>fn_GetWanIP |
SmtpMailer.au3
查看代码 AUTOIT
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | #Include <file.au3> Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") Global $oMyRet[2] Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") ;~ $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 ;~ MsgBox(0, "Error sending message", "Error code:" & @error & " Description:" & $rc) ;~ EndIf ; 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, ";") 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() $HexNumber = 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 |
-------------------------End-------------------------
发表评论

