使用投票按钮VBA重复发送电子邮件

时间:2014-11-14 08:50:29

标签: vba email outlook

我正在设置一个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

任何我出错的想法?​​

1 个答案:

答案 0 :(得分:0)

您的代码执行时Outlook是否正在运行?尝试添加一个名为Namespace.Logon的调用:

Set olApplication = WScript.CreateObject("Outlook.Application")
set olNS = olApplication.GetNamespace("MAPI")
olNS.Logon
Set olMail = olApplication.CreateItem(0)