Set ReplyRecipients in olMailItem

bigal.nz

Registered User.
Local time
Tomorrow, 00:30
Joined
Jul 10, 2016
Messages
92
I am in MS Access 2013 trying to set the Reply To address for a olMailItem with Outlook 2013. (https://msdn.microsoft.com/en-us/library/office/ff862985.aspx)

My current code is giving me:

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

Code:
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 = "test@test.com"
    .ReplyRecipients.Add "notatest@test.com"    <- 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

AG
 
I have Access 2013 and that code is not giving me any error. Suggest checking your referenced. For Outlook mine is "Microsoft Outlook 15.0 Object Library"
 
I have Access 2013 and that code is not giving me any error. Suggest checking your referenced. For Outlook mine is "Microsoft Outlook 15.0 Object Library"

Yes, since I posted that message I tried the same code on a standalone in Word (it doesnt have Access) and it ran ok.

I think it is something to do with our build on the work machines.

Interestingly I *can* manually set the reply to address on our work system, but for some reason via VBA fails!

Not sure where to go from here.

-Al
 
Since your at a loss for things to do I suggest opening Outlook, File, Office Account and Update Now under Office Updates. If that doesn't help then maybe Control Panel, Programs (Uninstall a program), right click on Microsoft Office, click Change and then do a repair.
 
Last edited:
You have to have permission to send on the accounts behalf set in exchange, although if you can manually do this it may not be a permissions issue.
 
You have to have permission to send on the accounts behalf set in exchange, although if you can manually do this it may not be a permissions issue.

Thanks but - Reply recipients is not send on behalf of - its setting the reply address.
 
Since your at a loss for things to do I suggest opening Outlook, File, Office Account and Update Now under Office Updates. If that doesn't help then maybe Control Panel, Programs (Uninstall a program), right click on Microsoft Office, click Change and then do a repair.

I think it might be to do with a (group?) policy at work - but its weird since I can do it manually.

I know that the group policy does stop scripts in outlook, but scripts in Access are fine, and we can send emails using references to the outlook objects.

Will let you know the outcome.
 
I was wondering what effect disabling macros in Outlook would have on Outlook macros run in other Applications. So I tried it. It doesn't have any effect. The same macro that doesn't run in Outlook runs fine in Access. That being as it is I don't see the point of disabling macros in Outlook.

When you choose to enable macros in Outlook the selection reads. "Enable all macros (not recommended, potentially dangerous code can run). So what? The "dangerous code" can run somewhere else anyway.
 
I was wondering what effect disabling macros in Outlook would have on Outlook macros run in other Applications. So I tried it. It doesn't have any effect. The same macro that doesn't run in Outlook runs fine in Access. That being as it is I don't see the point of disabling macros in Outlook.

When you choose to enable macros in Outlook the selection reads. "Enable all macros (not recommended, potentially dangerous code can run). So what? The "dangerous code" can run somewhere else anyway.

Yeah - I agree - but thats not my call.

I dont think you have all the functionality from Access you would have from Outlook - for example I dont think you can monitor for new emails from Access?
 

Users who are viewing this thread

Back
Top Bottom