【问题标题】:Result from MSXML2.XMLHTTP to send it throw SMTP从 MSXML2.XMLHTTP 发送的结果抛出 SMTP
【发布时间】:2013-08-19 22:15:43
【问题描述】:

我有 2 个脚本 1 检索我的公共 ip 并将其显示为 MSGBOX 第二个它发送邮件抛出 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

谢谢

【问题讨论】:

    标签: vbscript smtp


    【解决方案1】:

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

    objMessage.TextBody = o.responseText
    

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

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

    【讨论】:

    • 我可以在这个脚本的消息名称上添加日期和时间吗?像家用电脑IP(日期-时间)怎么添加呢?
    猜你喜欢
    • 2018-02-25
    • 2014-12-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-22
    • 2015-08-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多