How to stop OutLook Security Message programatically : A program is trying to access e-mail addresses, Allow access for 1 Minutes [duplicate]

只谈情不闲聊 提交于 2019-12-23 06:56:44

问题


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


回答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.




回答2:


If using Redemption 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


来源:https://stackoverflow.com/questions/49127940/how-to-stop-outlook-security-message-programatically-a-program-is-trying-to-ac

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!