codes吧 关注:11贴子:127
  • 0回复贴,共1

vb-获取机器ip发送指定邮箱

只看楼主收藏回复

Private Sub Form_Load()
Dim strName$
Dim objEmail As Object
Set objEmail = CreateObject("CDO.Message")
strName = "http://schemas.microsoft.com/cdo/configuration/"
objEmail.From = "send@163.com" '发送邮箱
objEmail.To = "jieshou@163.com" '接收邮箱
objEmail.Subject = getIP '得到ip
objEmail.Textbody = ""
objEmail.Configuration.Fields.Item(strName & "sendusing") = 2
objEmail.Configuration.Fields.Item(strName & "smtpserver") = "smtp.163.com"
objEmail.Configuration.Fields.Item(strName & "smtpserverport") = 25
objEmail.Configuration.Fields.Item(strName & "smtpauthenticate") = 1
objEmail.Configuration.Fields.Item(strName & "sendusername") = "发送邮箱用户名(发送邮箱@之前的部分)"
objEmail.Configuration.Fields.Item(strName & "sendpassword") = "发送邮箱密码"
objEmail.Configuration.Fields.Update
objEmail.Send
Set objEmail = Nothing
End Sub
Private Function getIP() As String
Dim strHtml$
With CreateObject("Microsoft.XMLHTTP")
.Open "GET", "http://www.ip138.com/ip2city.asp", False
.Send
strHtml = StrConv(.ResponseBody, vbUnicode)
End With
With CreateObject("vbscript.regExp")
.Pattern = "\[(.+?)\]"
getIP = .Execute(getHtmlStr(strHtml))(0).SubMatches(0)
End With
End Function


IP属地:江苏1楼2011-10-28 14:39回复