0

How to stop OutLook Security Message :

A program is trying to access e-mail addresses, Allow access for 1 Minutes

I want to stop this alert programatically and want to allow vba to access inbox of outlook,, since I dont have admin access for the outlook, I cant solve this manually going to trust center settings in outlook

My code works perfectly fine but op up security msgs need to check access for 10min again and again

Using excel vba I'm accessing outlook mails and downloading attachments from mail

Dim sa, ba As Date
Dim spa As Date

Set ObjO = CreateObject("Outlook.Application")
Set olNs = ObjO.GetNamespace("MAPI")
Set objFolder = olNs.GetDefaultFolder(6)

Debug.Print objFolder

spa = Date

Dim j
j = 0

For Each item1 In objFolder.Items

    sa = Format(item1.ReceivedTime, "dd-MM-yyyy")

    If sa <= spa Then
         If sa > spa - 30 And item1.SenderName = "PUJARY, SHRIKANTH" Then

At execution of item1.senderName line that security alert is popping up

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
harsha kazama
  • 159
  • 2
  • 4
  • 18
  • Can you "predict" this happening? (i.e. if you are doing 30 seconds work every 10 minutes then the 1-minute-access has expired, so you'll always be asked immediately. If you're doing something every 25 seconds, then the first, 4th, 7th, 10th etc item will all ask but the rest won't) If so, you might be able to use `SendKeys` to hit "OK" or "Allow" – Chronocidal Mar 06 '18 at 10:13
  • 4
    If it was possible to do this programmatically without admin access, what would be the point of having it there at all? –  Mar 06 '18 at 10:15
  • Did you try Application.displayAlerts =false ? – PankajKushwaha Mar 06 '18 at 10:19
  • The issue could be how your code is written, may we see your code? – 0m3r Mar 06 '18 at 11:26
  • I can use send keys but here I need to allow that for at least 10min which I needs to select that dropdown box which is not possible with send keys. clicking OK using send keys wont be the best solution here – harsha kazama Mar 08 '18 at 14:05
  • Application.display Alerts = false wont work already tried. it works within the excel but im using outlook and that alert related to outlook – harsha kazama Mar 08 '18 at 14:06
  • yeah you can see my code..i edited my post and updated the code in my post. please check it out – harsha kazama Mar 08 '18 at 14:09
  • Not possible to do this in Outlook VBA without administrative access/trust center. The trust center is explicitly not accessible via VBA, for (hopefully) obvious reasons. – David Zemens May 31 '18 at 22:36
  • I am been running into this and have been directed to use either CDO for Windows 2000. Which Redemption is a completely new library: RDO (Redemption Data Objects) that can function as a complete replacement of the CDO 1.21 library. http://www.dimastr.com/redemption/rdo_introduction.htm – SidCharming May 31 '18 at 22:34

2 Answers2

0

Ran into the same thing, there is no simple solution. In essence, the popup is there to prevent the exact thing you are trying to do: Controlling Outlook remotely. It was build as a defence against VBA/Macro viruses. So no, you cannot prevent this.

Solutions are to use the Extended Messaging API (MAPI) instead, but thats no easy task. Helper libraries can be bought, for example vbMAPI or Outlook Redemption

What's the difference? While the VBA method allows you to grab into a running instance of Outlook, MAPI requires you to log into the MAPI profile using username/password. This hasn't the security problems that tapping into Outlook has and is thus safe.

Oliver
  • 3,225
  • 1
  • 18
  • 12
0

If using Redemption (I am its author) is an option, modifying your script in a couple places would make it run without security prompts:

dim sItem
set sItem = CreateObject("Redemption.SafeMailItem")
For Each item1 In objFolder.Items
    sItem.Item = item1
    sa = Format(item1.ReceivedTime, "dd-MM-yyyy")
    If sa <= spa Then
         If sa > spa - 30 And sItem.SenderName = "PUJARY, SHRIKANTH" Then
Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78