我在MS Access 2013中尝试使用Outlook 2013设置olMailItem的回复地址。
我目前的代码给了我:
运行时错误'287'应用程序定义的错误或对象定义的错误
Private Sub email_button_click()
' *** SETUP OUTLOOK ***
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Set OutApp = New Outlook.Application
Set OutMail = OutApp.CreateItem(olMailItem)
' *** DO SOME OTHER STUFF ****
....
With OutMail
.Subject = "Test"
.Body = "Whatever"
.To = "[email protected]"
.ReplyRecipients.Add "[email protected]" <- Error here
.Display
End With
' *** TIDY UP ***
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
其他很多人似乎都能做到。即:
Change reply address in Outlook mail
http://www.ozgrid.com/forum/showthread.php?t=186882
http://www.vbaexpress.com/forum/archive/index.php/t-19993.html
谢谢
道格
在Outlook VBA或OutlookSpy脚本编辑器中运行以下脚本绝对没有问题。
Set OutMail = Application.CreateItem(olMailItem)
With OutMail
.Subject = "Test"
.Body = "Whatever"
.To = "[email protected]"
.ReplyRecipients.Add "[email protected]"
.Display
End With
如果Outlook未运行,请确保调用Namespace.Logon拳头:
set ns = Application.GetNamespace("MAPI")
ns.Logon
我在企业系统上看到过这种情况,其中组策略阻止了Outlook 2013上的VBA脚本。
解决方案是关闭GP。
只需再次列出,您正在“添加”收件人
.ReplyRecipients.Add "[email protected]"
.ReplyRecipients.Add "[email protected]"