'How to stop OutLook Security Message programatically : A program is trying to access e-mail addresses, Allow access for 1 Minutes [duplicate]
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
Solution 1:[1]
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.
Solution 2:[2]
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Oliver |
Solution 2 |