标题: [问题求助] [已解决]vbs怎样读取文本发送多行内容的邮件? [打印本页]
作者: 522235677 时间: 2013-3-30 19:38 标题: [已解决]vbs怎样读取文本发送多行内容的邮件?
本帖最后由 522235677 于 2019-5-22 18:30 编辑
- NameSpace = "http://schemas.microsoft.com/cdo/configuration/"
- set Email = CreateObject("CDO.Message")
- Email.From = "4324325@qq.com"
- Email.To = "thisexplorer@qq.com"
- Email.Subject = "来自 IP 来自:上海市 电信【101.229.24.63】的信息"
- Email.HTMLbody = "这里是正文"
- x="C:\fung.7z"
- y="C:\fung.7z"
- Set fso=CreateObject("Scripting.FileSystemObject")
- Set myfile=fso.OpenTextFile(x,1,Ture)
- c=myfile.readall
- myfile.Close
- Email.Textbody = c
- Email.AddAttachment y
- with Email.Configuration.Fields
- .Item(NameSpace&"sendusing") = 2
- .Item(NameSpace&"smtpserver") = "smtp.qq.com"
- .Item(NameSpace&"smtpserverport") = 25
- .Item(NameSpace&"smtpauthenticate") = 1
- .Item(NameSpace&"sendusername") = "4324324"
- .Item(NameSpace&"sendpassword") = "**************"
- .Update
- end with
- Email.Send
- Set Email=Nothing
复制代码
这个是发送邮件的vbs,测试可以发送。
Email.HTMLbody = "这里是正文"
但是发送的内容只能发送一行,我有一个txt文件,里面有N行文字,不想以附件形式发送,想以正文形式发送,请问要怎么修改。
谢了
作者: czjt1234 时间: 2013-3-31 07:18
- NameSpace = "http://schemas.microsoft.com/cdo/configuration/"
- set Email = CreateObject("CDO.Message")
- Email.From = "646397053@qq.com"
- Email.To = "thisexplorer@qq.com"
- Email.Subject = "来自 IP 来自:上海市 电信【101.229.24.63】的信息"
- x="C:\fung.7z"
- y="C:\fung.7z"
- Set fso=CreateObject("Scripting.FileSystemObject")
- Set myfile=fso.OpenTextFile(x,1,Ture)
- c=myfile.readall
- myfile.Close
- Email.HTMLbody = "这里是正文" &vbCRLf & c
- Email.AddAttachment y
- with Email.Configuration.Fields
- .Item(NameSpace&"sendusing") = 2
- .Item(NameSpace&"smtpserver") = "smtp.qq.com"
- .Item(NameSpace&"smtpserverport") = 25
- .Item(NameSpace&"smtpauthenticate") = 1
- .Item(NameSpace&"sendusername") = "646397053"
- .Item(NameSpace&"sendpassword") = "**************"
- .Update
- end with
- Email.Send
- Set Email=Nothing
复制代码
作者: 522235677 时间: 2013-3-31 10:07
本帖最后由 522235677 于 2013-3-31 10:10 编辑
回复 2# czjt1234
你这个改是可以的
这个正文怎么不是自动换行啊,看起来很乱,可以改下吗?
作者: czjt1234 时间: 2013-3-31 16:39
本帖最后由 czjt1234 于 2013-3-31 16:40 编辑
- NameSpace = "http://schemas.microsoft.com/cdo/configuration/"
- set Email = CreateObject("CDO.Message")
- Email.From = "646397053@qq.com"
- Email.To = "thisexplorer@qq.com"
- Email.Subject = "来自 IP 来自:上海市 电信【101.229.24.63】的信息"
- x="C:\fung.7z"
- y="C:\fung.7z"
- Set fso=CreateObject("Scripting.FileSystemObject")
- Set myfile=fso.OpenTextFile(x,1,Ture)
- c=myfile.readall
- myfile.Close
- Email.HTMLbody = Replace("这里是正文" &vbCRLf & c, vbCrLf ,"<br>")
- Email.AddAttachment y
- with Email.Configuration.Fields
- .Item(NameSpace&"sendusing") = 2
- .Item(NameSpace&"smtpserver") = "smtp.qq.com"
- .Item(NameSpace&"smtpserverport") = 25
- .Item(NameSpace&"smtpauthenticate") = 1
- .Item(NameSpace&"sendusername") = "646397053"
- .Item(NameSpace&"sendpassword") = "**************"
- .Update
- end with
- Email.Send
- Set Email=Nothing
复制代码
没测试,你试试看
作者: 522235677 时间: 2013-3-31 16:59
回复 4# czjt1234
非常感谢。好的
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |