0

我有 2 个脚本 1 检索我的公共 ip 并将其显示为 MSGBOX,第二个用于发送邮件 throw SMTP

我希望 SMTP 将第一个脚本的结果发送给我,无论如何如何 mirge 两者?

这是为了获得我的公共 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

谢谢

4

1 回答 1

0

只需将响应文本分配给消息正文:

objMessage.TextBody = o.responseText

日期和时间可以像这样添加到主题中:

objMessage.Subject = "Home PC IP (" & Now & ")"
于 2013-08-19T09:38:57.390 回答