[英]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 中收到标准的安全提示。您的选项是:
Application
object. COM add-ins don't trigger such security prompts.开发一个 COM 加载项,它可以访问受信任的Application
object。COM 加载项不会触发此类安全提示。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.