Outlook - Runtime 287 error accessing HTMLBody of email

Asked By Alan on 05-Apr-11 08:35 AM
Hi, I'm a novice programmer trying to make my email maintenance simpler. I'm using XP and Outlook 2003 and trying to create a macro that will save attachments in a chosen location and update the email body to have a hyperlink to that location. After cloning code from this and other sites I have got my macro working fine on the machine I developed it on. However, when I run it on my works Outlook client I get "Run-time error '287': Application-defined or object-defined error"
On investigation the error is caused by the line
myItem.HTMLBody = Replace(myItem.HTMLBody, "</BODY>", strSave & "</BODY>", , , vbTextCompare)
where strSave is my formatted string containing the links

On further trial and error on the office machine I find I can do the following OK
strTemp = "<HTML><BODY> Fred </BODY></HTML>"
myItem.HTMLBody = strTemp
myItem.Save
This does save my item with just the text Fred in it

However, if I try to do
strTemp = "<HTML><BODY> Fred </BODY></HTML>"
myItem.HTMLBody = strTemp
strTemp = myItem.HTMLBody

I get the 287 error on the strTemp = myItem.HTMLBody line

I'm guessing it must be something to do with security settings somewhere but it seems weird to me that I can set HTMLBody but can't get at the original contents of it.

Any suggestions ?
Ravinder Jamgotre replied to Alan on 05-Apr-11 09:04 AM
Have you checked the macro security level on the live machine, compare it with the security from the dev machine. Change accordingly.

Check the outlook versions also, patches, service packs etc.
Alan replied to Ravinder Jamgotre on 05-Apr-11 11:45 AM
The macro Security settings are the same. Dev machine Outlook is 2003 (11.8217.824) SP3 and the office machine is 11.8325.8329 SP3. Both machines are XP Pro 5.1.2600 SP3
Can't see any other differences
Ravinder Jamgotre replied to Alan on 05-Apr-11 11:47 AM
There is a difference look at the (  ) the patch numbers are different there is a security update or something installed on the office machine than that of the dev machine.

Goto Add/Remove programs and see installed updates, compare and remove the conflicting security update on office machine and all will be fine.

Good luck!