我正在设置一个VBS / WSH / BAT脚本,允许用户每隔一天安排一次电子邮件,并附上投票按钮。
我找到了一个旧脚本,它似乎做了我需要的但是不断收到错误
错误:对象必需:'收件人' 代码:800A01A8
Dim olApplication
Dim olMail
Set olApplication = WScript.CreateObject("Outlook.Application")
Set olMail = olApplication.CreateItem(0)
With olMail
.Subject = "Subject line"
.Body = "Any text you might want to include."
.Recipients.Add("UserA;UserB;UserC")
.VotingOptions = "Available Immediately;Available Soon;Unavailable"
End With
If Recipients.ResolveAll Then
olMail.Send
End If
任何我出错的想法?
答案 0 :(得分:0)
您的代码执行时Outlook是否正在运行?尝试添加一个名为Namespace.Logon的调用:
Set olApplication = WScript.CreateObject("Outlook.Application")
set olNS = olApplication.GetNamespace("MAPI")
olNS.Logon
Set olMail = olApplication.CreateItem(0)