来自MSXML2.XMLHTTP的结果发送它抛出SMTP

时间:2013-08-18 11:22:14

标签: vbscript smtp

我有2个脚本1检索我的公共IP并将其显示为MSGBOX 第二个发送邮件抛出SMTP

我希望SMTP向我发送第一个脚本的结果,无论如何如何反映它们?

这是为了获得我的PUBLIC IP(工作正常)

Dim o
Set o = CreateObject("MSXML2.XMLHTTP")
o.open "GET", "http://api.externalip.net/ip", False
o.send
If err.number = 0 then    
    MsgBox o.responseText
Else
    MsgBox "error " & err.number & ": " & err.description
End If

这将发送邮件抛出SMTP

Set objMessage = CreateObject("CDO.Message") 
objMessage.Subject = "Home PC IP" 
objMessage.From = "***********@gmail.com" 
objMessage.To = "***********@gmail.com" 
objMessage.TextBody = "*I WANT TO ADD HERE THE o.responseText From the First Scrip*"



objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"


objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = true

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername") = "***********"

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "************"


objMessage.Configuration.Fields.Update



objMessage.Send

由于

1 个答案:

答案 0 :(得分:0)

只需将响应文本分配给邮件正文:

objMessage.TextBody = o.responseText

日期和时间可以添加到主题中,如下所示:

objMessage.Subject = "Home PC IP (" & Now & ")"