Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Outlook and VBA (http://www.outlookbanter.com/outlook-vba/)
-   -   a program is trying to access e-mail address - how do I avoid this (http://www.outlookbanter.com/outlook-vba/22805-program-trying-access-e-mail.html)

marie August 3rd 06 11:48 PM

a program is trying to access e-mail address - how do I avoid this
 
In my vba code I'm receiving the following error "a program is trying
to access e-mail addresses you have stored in outlook. Do you want to
allow this?..." I'm not accessing addresses at all so I don't know why
the error message is appearing. I've been able to isolate the error to
the final line of code below where I'm appending text - does anyone
know how I can avoid this msg from appearing??



Sub test()
Dim myOlApp As New Outlook.Application

'check if this is a mail object first
If myOlApp.ActiveInspector.CurrentItem.Class = olMail Then
myOlApp.ActiveInspector.CurrentItem.Subject = "test"

'append to email body
myOlApp.ActiveInspector.CurrentItem.Body =
myOlApp.ActiveInspector.CurrentItem.Body & " appending new text"

End If
End Sub


Sue Mosher [MVP-Outlook] August 4th 06 05:00 AM

a program is trying to access e-mail address - how do I avoid this
 
The Body property is also subject to the "object model guard." See http://www.outlookcode.com/d/sec.htm for your options.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"marie" wrote in message oups.com...
In my vba code I'm receiving the following error "a program is trying
to access e-mail addresses you have stored in outlook. Do you want to
allow this?..." I'm not accessing addresses at all so I don't know why
the error message is appearing. I've been able to isolate the error to
the final line of code below where I'm appending text - does anyone
know how I can avoid this msg from appearing??



Sub test()
Dim myOlApp As New Outlook.Application

'check if this is a mail object first
If myOlApp.ActiveInspector.CurrentItem.Class = olMail Then
myOlApp.ActiveInspector.CurrentItem.Subject = "test"

'append to email body
myOlApp.ActiveInspector.CurrentItem.Body =
myOlApp.ActiveInspector.CurrentItem.Body & " appending new text"

End If
End Sub



All times are GMT +1. The time now is 08:19 AM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com