olMailItem - ReplyRecipients.Add

问题描述 投票:1回答:3

我在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

谢谢

道格

vba ms-access outlook access-vba ms-access-2013
3个回答
1
投票

在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

0
投票

我在企业系统上看到过这种情况,其中组策略阻止了Outlook 2013上的VBA脚本。

解决方案是关闭GP。


0
投票

只需再次列出,您正在“添加”收件人

   .ReplyRecipients.Add "[email protected]"
   .ReplyRecipients.Add "[email protected]"
© www.soinside.com 2019 - 2024. All rights reserved.