'olMailItem - ReplyRecipients.Add

I am in MS Access 2013 trying to set the Reply To address for a olMailItem with Outlook 2013.

My current code is giving me:

Run-time error '287' Application-defined or object-defined error

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

Plenty of others seem to be able to do it. ie :

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

Thanks

Doug



Solution 1:[1]

I have absolutely no problem running the following script in Outlook VBA or OutlookSpy (I am its author) script editor.

Set OutMail = Application.CreateItem(olMailItem)
With OutMail
    .Subject = "Test"
    .Body = "Whatever"
    .To = "[email protected]"
    .ReplyRecipients.Add "[email protected]"
    .Display
End With

If Outlook is not running, make sure you call Namespace.Logon fist:

set ns = Application.GetNamespace("MAPI")
ns.Logon

Solution 2:[2]

I have seen this on a Enterprise system where the group policy was blocking VBA scripts on Outlook 2013.

The solution is to turn the GP off.

Solution 3:[3]

Just list it a second time, you are "adding" recipiants

   .ReplyRecipients.Add "[email protected]"
   .ReplyRecipients.Add "[email protected]"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Al Grant
Solution 3 Xyloz Quin