简体   繁体   English

仅针对特定的 powershell 脚本抑制 Outlook“此程序正在尝试访问电子邮件”弹出窗口

[英]Suppressing Outlook "This program is trying to access E-mail" pop-up for specific powershell script only

When I run the following powershell script to send an e-mail:当我运行以下 powershell 脚本发送电子邮件时:

$Outlook = New-Object -ComObject Outlook.Application
$file = Get-ChildItem -Path "H:\TP65655\IDX CVA\UAT" -Include *.idx -Recurse | Where {$_.CreationTime -gt (Get-Date).AddDays(-1)}
$atts = $file.fullname
$Mail = $Outlook.CreateItem(0)
$Mail.To = "email@domain.com"
$Mail.Subject = "Testing E-mail Automation"
$Mail.Body = "UAT TEST"
Try
{
    $Mail.Attachments.Add($atts)
    $Mail.Send()
    Write-Host "Mail Sent Successfully"
    Read-Host -Prompt “Press Enter to exit”
}
Catch
{
    Write-Host "File Not Attached Successfully, Please Try Again"
    Read-Host -Prompt “Press Enter to exit”
    Exit
}

The following pops up from Outlook:从Outlook弹出如下内容:

Pop Up from Outlook从 Outlook 弹出

Is there any way I can remove this without changing the programmatic access in Trust Center to "Never" as this is an organization desktop and that option is not feasible.有什么方法可以删除它而不将信任中心中的编程访问更改为“从不”,因为这是一个组织桌面并且该选项不可行。

You get a standard security prompt in Outlook. Your options are:您会在 Outlook 中收到标准的安全提示。您的选项是:

  1. Use the Outlook Security Manager component which allows to disable such warnings at run-time dynamically.使用允许在运行时动态禁用此类警告的Outlook 安全管理器组件。
  2. Use a low-level API on which Outlook is based on - Extended MAPI.使用低级 API,Outlook 基于 - 扩展 MAPI。 It doesn't throw security warnings or pop-ups.它不会抛出安全警告或弹出窗口。 Or just consider using any wrapper around a low-level API such as Redemption.或者只考虑使用任何围绕低级 API 的包装器,例如 Redemption。
  3. Develop a COM add-in which has access to the trusted Application object. COM add-ins don't trigger such security prompts.开发一个 COM 加载项,它可以访问受信任的Application object。COM 加载项不会触发此类安全提示。
  4. Deploy security settings via GPO.通过 GPO 部署安全设置。
  5. Install any antivirus software with latest updates.安装任何具有最新更新的防病毒软件。

You may find the "A program is trying to send an e-mail message on your behalf" warning in Outlook article in MSDN helpful.您可能会发现 MSDN 中 Outlook 文章中的“程序正在尝试代表您发送电子邮件”警告很有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM