我对vbscript很新,但这是我到目前为止所做的,但似乎没有工作:
<script type="text/vbscript">
Sub Senmail()
Dim objOutlook As Object
Dim objOutlookMsg As Object
Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(0)
With objOutlookMsg
.To = "eric@gmail.com"
.Cc = "name@email.com"
.Subject = "Hello World (one more time)..."
.Body = "This is the body of message"
.HTMLBody = "HTML version of message"
.Send
End With
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
End Sub
</script>
任何输入都将不胜感激!或者我可以发送电子邮件的任何其他方式是我的... ....
答案 0 :(得分:0)
对于初学者,请从As Object
语句中删除Dim
。在VBScript中,您不能将变量As
声明为任何特定的数据类型。一切都是变种。
Dim objOutlook
Dim objOutlookMsg
如果您需要更多帮助,那么您可能想告诉我们一些关于您的问题的更具体的信息,而不是“似乎没有工作”,例如你得到了什么错误或错误的行为。
答案 1 :(得分:0)
这是使用CDO / SMTP的一种方式
Sub SendMail()
Set objMsg = CreateObject("CDO.Message")
Set objConfig = CreateObject("CDO.Configuration")
Set objFields = objConfig.Fields
With objFields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "YourSMTPServer"
.Update
End With
With objMsg
Set.Configuration = objConfig
.To = "eric@gmail.com"
.CC = "name@gmail.com"
.From = "you@gmail.com"
.Subject = "Hello World"
.HTMLBody = "This is the body of message"
.Fields.Update
.Send
End with
Set objMsg = Nothing
Set objConfig = Nothing
End Sub