0

We have a lot of emails saved to a folder on the file system to be processed by extracting text from the message bodies. Office 2010.

Dim app As Object
Dim msg As Object
dim msg_body as string

Set app = New Outlook.Application
Set msg = app.CreateItemFromTemplate("c:\path\to\message.msg")

msg_body = msg.body

This code works fine on my laptop however when I use it on the work network it gives error '287'.

While debugging I noticed that I can view msg msg.display and even change the body with msg.body = "some text". However I cannot read the message body. Also tried msg.HTMLbody which could not be read.

6
  • Is the failing code exactly the same? If not, how is it different? Commented Sep 25, 2017 at 5:26
  • Exactly the same - the difference is that it is on the work network instead of my laptop (which is not connected to the network). We are guessing it might be due to vba trying to look up the network address book and having permission problems - however we don't know how to turn off this behaviour (if it is responsible). Commented Sep 25, 2017 at 5:37
  • Does that happen for a particular MSG file only? Or all of them? Commented Sep 25, 2017 at 16:19
  • All of them. Even created test email with the word test and nothing else and it still didn't work. Although I could set the msg.body = "test" and that worked - it is strange I could write but not read, given that msg.display works! Commented Sep 25, 2017 at 19:15
  • Code works fine in my network environment, able to read and change message body, tested both unicode and non-unicode message. Though I used Set app = CreateObject("Outlook.Application") rather than Early binding. Commented Sep 27, 2017 at 5:53

1 Answer 1

1

The most probable cause is your company's policies. Check this registry key to solve the SaveAs (change the 16 to your office version). hkcu\software\policies\microsoft\office\16.0\outlook\security\promptoomsaveas

You can change the value to 2, or ask your system administrator to create a new GPO.

More information on this and other security configurations in:

https://support.microsoft.com/en-za/help/926512/information-for-administrators-about-e-mail-security-settings-in-outlo

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.