Outlook 2016 - “Run-time error '287': Application-defined or object-defined error” while using CurrentItem.Saveas or CurrentItem.HTMLBody

风格不统一 提交于 2020-02-06 06:33:07

问题


We have an Access Database running for quite a few years under "Office 2010" but now we have to change to Office 365 and are getting this annoying error with the code below:

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, but the error ocurrs in the line:

 "olItemSaida.SaveAs "C\TEstes\" & strProcesso & ".Msg", olMSGUnicode"

Can anyone help, please?


回答1:


Problem solved.

It was all about Security Policies for Outlook 2016.

Now the code runs like it ever did.

Thanks anyway.




回答2:


  1. Make sure the path string is correct.
  2. Try to specify another type to save with - OlSaveAsType.
  3. It may be a security issue when automating Outlook from an external application. See "A program is trying to send an e-mail message on your behalf" warning in Outlook for more information.


来源:https://stackoverflow.com/questions/57204574/outlook-2016-run-time-error-287-application-defined-or-object-defined-erro

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!