PC Review


Reply
Thread Tools Rate Thread

How to avoid Security PopUp in Outlook 2003

 
 
Greg
Guest
Posts: n/a
 
      17th Aug 2006
I am trying to write a couple of simple macros for Microsoft Outlook.
When I run the macros either manually or based on a rule when new email
is received I get a popup security warning that "A program is trying to
access e-mail addresses you have stored in Outlook "

I am running Microsoft Outlook 2003 on Windows 2000. I would like to
stop the popups from aplearing as it gets annoying to have to click ok
each time and I would like the first macro to run in the background on
selected emails on receipt. Is there a way to do this direct from VBA
without purchasing a 3rd party product?

Below are the macros I am trying to run

Macro #1: called by a rule when mail is received

Sub testMacro1(MyMail As MailItem)
Dim x As String
Dim strID As String

'------------------------------------------------------------------------
Dim muOlApp As Outlook.Application
'------------------------------------------------------------------------

Dim olNS As Outlook.NameSpace
Dim olMail As Outlook.MailItem
Dim mySubj, myMsg, mySender, myMsg2 As String
Dim rs As ADODB.Recordset
Dim fld As ADODB.Field
Dim sql As String

strID = MyMail.EntryID

(I have tried the following two lines and the line commented out below
them with the same results)
'------------------------------------------------------------------------
Set myOlApp = Application
Set olNS = myOlApp.GetNamespace("MAPI")
'------------------------------------------------------------------------
'Set olNS = Application.GetNamespace("MAPI")

Set olMail = olNS.GetItemFromID(strID)
mySubj = olMail.Subject
myMsg = olMail.Body (POPUP MESSAGE)
mySender = olMail.SenderEmailAddress (POPUP MESSAGE)

Set olMail = Nothing
Set olNS = Nothing

End Sub


Macro#2: Called manually from the toolbar
Sub addNewReq()
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim fld As ADODB.Field
Dim sql As String
Dim x As Long
Dim tst As String

mybody = ActiveInspector.CurrentItem.Body
mySubj = ActiveInspector.CurrentItem.Subject
mySender = ActiveInspector.CurrentItem.SenderEmailAddress
If InStr(1, mySender, "@") = 0 Then
x = InStrRev(mySender, "=")
mySender = Right$(mySender, Len(mySender) - x)
End If
end sub

I would appreciate any suggestions.

 
Reply With Quote
 
 
 
 
Sue Mosher [MVP-Outlook]
Guest
Posts: n/a
 
      17th Aug 2006
In Macro #1: Try changing olMail to msg or some other variable name. olMail is a member of one of Outlook's enumerations, so it may not work well as a variable name.

In Macro #2: ActiveInspector.CurrentItem.Body should properly be Application.ActiveInspector.CurrentItem.Body, but I suspect it makes no real difference.

Most important: Go to Help | About Microsoft Outlook and see what it says for "Security Mode." If it's not "User-controlled," then the VBA Application object is not "trusted" with regard to the Outlook "object model guard." You'll need to consider using one of the other approaches listed at http://www.outlookcode.com/d/sec.htm. Redemption is highly recommended.
--
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

"Greg" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
>I am trying to write a couple of simple macros for Microsoft Outlook.
> When I run the macros either manually or based on a rule when new email
> is received I get a popup security warning that "A program is trying to
> access e-mail addresses you have stored in Outlook "
>
> I am running Microsoft Outlook 2003 on Windows 2000. I would like to
> stop the popups from aplearing as it gets annoying to have to click ok
> each time and I would like the first macro to run in the background on
> selected emails on receipt. Is there a way to do this direct from VBA
> without purchasing a 3rd party product?
>
> Below are the macros I am trying to run
>
> Macro #1: called by a rule when mail is received
>
> Sub testMacro1(MyMail As MailItem)
> Dim x As String
> Dim strID As String
>
> '------------------------------------------------------------------------
> Dim muOlApp As Outlook.Application
> '------------------------------------------------------------------------
>
> Dim olNS As Outlook.NameSpace
> Dim olMail As Outlook.MailItem
> Dim mySubj, myMsg, mySender, myMsg2 As String
> Dim rs As ADODB.Recordset
> Dim fld As ADODB.Field
> Dim sql As String
>
> strID = MyMail.EntryID
>
> (I have tried the following two lines and the line commented out below
> them with the same results)
> '------------------------------------------------------------------------
> Set myOlApp = Application
> Set olNS = myOlApp.GetNamespace("MAPI")
> '------------------------------------------------------------------------
> 'Set olNS = Application.GetNamespace("MAPI")
>
> Set olMail = olNS.GetItemFromID(strID)
> mySubj = olMail.Subject
> myMsg = olMail.Body (POPUP MESSAGE)
> mySender = olMail.SenderEmailAddress (POPUP MESSAGE)
>
> Set olMail = Nothing
> Set olNS = Nothing
>
> End Sub
>
>
> Macro#2: Called manually from the toolbar
> Sub addNewReq()
> Dim conn As ADODB.Connection
> Dim rs As ADODB.Recordset
> Dim fld As ADODB.Field
> Dim sql As String
> Dim x As Long
> Dim tst As String
>
> mybody = ActiveInspector.CurrentItem.Body
> mySubj = ActiveInspector.CurrentItem.Subject
> mySender = ActiveInspector.CurrentItem.SenderEmailAddress
> If InStr(1, mySender, "@") = 0 Then
> x = InStrRev(mySender, "=")
> mySender = Right$(mySender, Len(mySender) - x)
> End If
> end sub
>
> I would appreciate any suggestions.
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to avoid security alerts in Outlook Add in Abhi. Microsoft Outlook Form Programming 3 11th Sep 2008 02:14 PM
avoid security popup Rudolf Microsoft Access Security 0 8th Jun 2008 10:35 AM
avoid security messages when automating outlook using access 2003 =?Utf-8?B?U0Ft?= Microsoft Outlook Discussion 8 31st Jul 2007 11:42 PM
How to avoid the outlook popup warning when retrieving an MailItem Michael H Microsoft Outlook Interoperability 5 16th Jan 2006 03:43 PM
how can we avoid security popup in Outlook 2003? =?Utf-8?B?TmFkZWVt?= Microsoft Outlook VBA Programming 6 12th Nov 2005 12:23 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:05 PM.