博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
VB/VBS 发送邮件代码
阅读量:6117 次
发布时间:2019-06-21

本文共 2563 字,大约阅读时间需要 8 分钟。

vbs发送邮件代码

NameSpace = " "
Set Email = CreateObject("CDO.Message")
Email.From = " "
Email.To =" "
Email.Subject = "say hello"
Email.Textbody = " test body "
Email.AddAttachment ""
With Email.Configuration.Fields
.Item(NameSpace&"sendusing") = 2
.Item(NameSpace&"smtpserver") = "smtp.sohu.com"
.Item(NameSpace&"smtpserverport") = 25
.Item(NameSpace&"smtpauthenticate") = 1
.Item(NameSpace&"sendusername") = "benio_guo"
.Item(NameSpace&"sendpassword") = "q1w2e3"
.Update
End With
Email.Send
下面是 vb版

Private Sub Form_Load()

    Dim NameS As String
    Dim Email As Object
   
    NameS = ""
   
    Set Email = CreateObject("CDO.Message")
    Email.From = ""
    Email.To = ""
    Email.Subject = "say hello"
    Email.Textbody = "test body"
    Email.AddAttachment "C:\test.txt"
    Email.Configuration.Fields.Item(NameS & "sendusing") = 2
    Email.Configuration.Fieds.Item(NameS & "smtpserver") = "smtp.sohu.com"
    Email.Configuration.Fields.Item(NameS & "smtpserverport") = 25
    Email.Configuration.Fields.Item(NameS & "smtpauthenticate") = 1
    Email.Configuration.Fields.Item(NameS & "sendusername") = "benio_guo"
    Email.Configuration.Fields.Item(NameS & "sendpassword") = "q1w2e3"
    Email.Configuration.Fields.Update
    Email.Send
End Sub

第二:
'把以下文件存为vbs文件,双击就可运行,也可以放到Job里去运行。
Set cdo = CreateObject( "CDO.Message ")
strCfg = "http://schemas.microsoft.com/cdo/configuration/ "
With cdo
.Sender = "发送者邮件地址 "
.From = "发送者邮件地址 "
.To = "接收者邮件地址 "
.Fields( "urn:schemas:mailheader:X-Priority ") = 1
.Fields.Update
.Subject = "邮件标题 "
.TextBody = "邮件内容 "
.Configuration(strCfg & "SendUsing ") = 2
.Configuration(strCfg & "smtpserver ") = "发送邮件服务器地址 "
.Configuration(strCfg & "sendusername ") = "发送者邮箱帐号 "
.Configuration(strCfg & "sendpassword ") = "发送者邮箱密码 "
.Configuration.Fields.Update
.send
End With
msgbox "发送完成 "

NameSpace = "http://schemas.microsoft.com/cdo/configuration/"
set Email = CreateObject("CDO.Message")
Email.From = "Benio_Guo@cn.*.com"
Email.To = "Benio_Guo@cn.*.com"
Email.Subject = " Daily Planned Order Report_"&year(now())&month(now())&day(now())
'x="C:\test.txt"
y="K:\ASCP\reports\APS_PLAN_ORDER_FOR_RELEASE_BY_WEEKLY_DR.xls"
'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") = "dm01"
.Item(NameSpace&"smtpserverport") = 25
.Item(NameSpace&"smtpauthenticate") = 1
.Item(NameSpace&"sendusername") = "benio guo"  
.Item(NameSpace&"sendpassword") = "*pwd*"
.Update
end with
Email.Send
Set Email=Nothing
 

转载地址:http://bcvka.baihongyu.com/

你可能感兴趣的文章
JQuery-EasyUI Datagrid数据行鼠标悬停/离开事件(onMouseOver/onMouseOut)
查看>>
并发和并行的区别
查看>>
div+css 你知道多少?值得一看
查看>>
全网最详细的Git学习系列之介绍各个Git图形客户端(Windows、Linux、Mac系统皆适用ing)(图文详解)...
查看>>
NET插件系统之一,开头:MEF的一些疑问和相关思考
查看>>
iOS:分组的表格视图UITableView,可以折叠和展开
查看>>
GNU make manual 翻译( 九十八)
查看>>
一个人的渺小与微不足道。
查看>>
不同场景下 MySQL 的迁移方案
查看>>
GNU make manual 翻译( 一百六十四)
查看>>
ASP.NET中 DetailsView(详细视图)的使用前台绑定
查看>>
Hadoop示例程序WordCount详解及实例
查看>>
一道面试题带来的前端优化——实现星星点评
查看>>
CoderZh首款Python联机对战游戏 - NancyTetris1.0倾情发布(二)
查看>>
poj3250 Bad Hair Day
查看>>
WPF/Silverlight的数据绑定设计的真糟糕
查看>>
SQL复制多表数据
查看>>
python3-类与对象
查看>>
Python正则表达式指南
查看>>
22.4. rpcinfo
查看>>