[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[问题求助] 有关VBS 自动发MAIL的问题询问

在VBS中有关MAIL的语句
MailObject.Subject = " "

MailObject.Textbody = "  "     ###这行附加的字符可以是中文的吗?我测试用中文的会出错,若想用中文要如何写呢?

MailObject.AddAttachment "d:\vbs_testall.txt"   ###这行路径可以是中文的吗?

有谁测试过请告知谢谢!!!

回复 1# depsyq

以下是我使用过的实例
  1. ' 用 ServerXMLHTTP 从 api.hostip.info 或 ip138 获取 IP 地址
  2. Dim WinHttpReq
  3. Set WinHttpReq = CreateObject("Msxml2.ServerXMLHTTP")
  4. ' WinHttpReq.Open "GET", "http://iframe.ip138.com/ic.asp"
  5. WinHttpReq.Open "GET", "http://api.hostip.info/get_html.php"
  6. WinHttpReq.Send
  7. '正则表达式解析出外网IP
  8. Dim MyRegExp
  9. Set MyRegExp = CreateObject("VBScript.RegExp")
  10. MyRegExp.Pattern = "((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)"
  11. MyRegExp.IgnoreCase = True
  12. MyRegExp.Global = True
  13. Dim Matches
  14. Set Matches = MyRegExp.Execute(WinHttpReq.ResponseText)
  15. MsgBox Matches.Item(0).Value
  16. URL_HOMEPAGE = "http://" & Matches.Item(0).Value
  17. ' SendEmail
  18. NameSpace = "http://schemas.microsoft.com/cdo/configuration/"
  19. Set Email = CreateObject("CDO.Message")
  20. Email.From = "neorobin@163.com"
  21. Email.To = "neorobin@163.com"
  22. Email.Subject = "我的 IP 地址"
  23. Email.HTMLBody = "<a href=""" & URL_HOMEPAGE & """" & " target=""_blank"">" & URL_HOMEPAGE & "</a><br>最后更新: " & now()
  24. Email.AddAttachment "D:\桌面\TEST.TXT"
  25. With Email.Configuration.Fields
  26.     .Item(NameSpace&"sendusing") = 2
  27.     .Item(NameSpace&"smtpserver") = "smtp.163.com" 'smtp服务器地址
  28.     .Item(NameSpace&"smtpserverport") = 25
  29.     .Item(NameSpace&"smtpauthenticate") = 1
  30.     .Item(NameSpace&"sendusername") = "neorobin"
  31.     .Item(NameSpace&"sendpassword") = "******"
  32.     .Update
  33. End With
  34. Email.Send
  35. set WinHttpReq = nothing
  36. set MyRegExp = nothing
  37. set Matches = nothing
  38. set Email = nothing
复制代码

TOP

第 31 行 改成
  1. Email.TEXTBody = "最后更新: " & now()
复制代码
一样发送成功

TOP

set WinHttpReq = nothing
set MyRegExp = nothing
set Matches = nothing
set Email = nothing


这些什么意思

TOP

回复 4# depsyq


清理对象, 对此的必要性, 方式, 我并没有认识.

此文谈到这个问题
http://blogs.msdn.com/b/ericlipp ... cts-to-nothing.aspx

TOP

返回列表