Reputation: 11
We have an Access database running under Office 2010.
We have to change to Office 365 and get
Run-time error '287': Application-defined or object-defined error
with:
Dim olAppSaida As Outlook.Application
Dim olItemSaida As Outlook.MailItem
Set olAppSaida = CreateObject("Outlook.application")
Set olItemSaida = olAppSaida.ActiveInspector.CurrentItem
If Not TypeName(olItemSaida) = "Nothing" Then
olItemSaida.SaveAs "C\TEstes\" & strProcesso & ".Msg", olMSGUnicode
End If
The reference to Outlook XX.X library is checked. The error occurs in the line:
olItemSaida.SaveAs "C\TEstes\" & strProcesso & ".Msg", olMSGUnicode
Upvotes: 0
Views: 13515
Reputation: 121
As @mariodcm says, the problem is related to Security Policies. He pointed me to the solution. To make long history short:
Found out that it was blocked by the following policy: HKEY_CURRENT_USER\Software\Policies\Microsoft\office\16.0\outlook\security\promptoomsend
The key was set to 0 = Automatically Deny. Changing the key to 2 = Automatically Approve solved the problem.
More information: https://answers.microsoft.com/en-us/msoffice/forum/all/office-365-proplus-word-vba-sending-or-saving-mail/5654cfb4-9671-4900-aec4-93ee06e62c40
Upvotes: 1
Reputation: 11
Problem solved.
It was all about Security Policies for Outlook 2016.
Now the code runs like it ever did.
Thanks anyway.
Upvotes: 1
Reputation: 49453
OlSaveAsType
. Upvotes: 0