使用获取外网IP并发送邮箱

新建文本文档拷贝保存并修改后缀为“.vbs”即可双击运行。

Function GetIPAddress()
    Const url="http://iframe.ip138.com/ic.asp"
    Set http=CreateObject("msxml2.xmlhttp")
    Set regex=New RegExp:regex.pattern="(\d{1,3}\.){3}\d{1,3}"
    http.open "get",url,False
    http.send
    Do Until http.readyState=4
        WScript.Sleep 100
    Loop
    GetIPAddress=regex.Execute(http.responseText)(0)
End Function

Function MailTo(MailAddress)
    Dim NameSpace, MailObject
    
    NameSpace = "http://schemas.microsoft.com/cdo/configuration/"
    
    Set MailObject = CreateObject("CDO.Message")
    MailObject.From = "发送邮箱"
    MailObject.To = MailAddress
    MailObject.Subject = "IP Address Information"
    
    MailObject.Textbody = Now & ": " & GetIPAddress()
    
    MailObject.Configuration.Fields.Item(NameSpace & "sendusing") = 2
    MailObject.Configuration.Fields.Item(NameSpace & "smtpserver") = "smtp.163.com"    ''发送端的设置
    MailObject.Configuration.Fields.Item(NameSpace & "smtpserverport") = 25
    MailObject.Configuration.Fields.Item(NameSpace & "smtpauthenticate") = 1
    MailObject.Configuration.Fields.Item(NameSpace & "sendusername") = "发送邮箱用户名:@前面的"
    MailObject.Configuration.Fields.Item(NameSpace & "sendpassword") = "发送邮箱密码"
    
    MailObject.Configuration.Fields.Update
    MailObject.Send
End Function

MailTo ("接收邮箱")

Leave a Reply

Your email address will not be published. Required fields are marked *

Translate »