简体   繁体   中英

Send Email (Outlook 2016) via Powershell

i searched a lot and found lots of solutions like that:

$ol = New-Object -comObject Outlook.Application  
$mail = $ol.CreateItem(0)
$mail.Recipients.Add("empfänger@domain.com")
$mail.Subject = "Betreff: Info fuer den Empfaenger"
$mail.Body = "Hier können Sie Ihren Nachrichtentext übergeben. Gerne auch in Form einer Variablen. Ihre Informationen, sollten dann aber als Objekt-Typ STRING vorliegen."
$Mail.Send()

but it doesn't work. Know anyone this problem?

(Outlook is manually working; i am not searching an solution with smtp adress..)

Most probably you faced with a security prompt/issue in Outlook. The Send method is sensitive, so if you automate Outlook for sending emails and calling the Send method in external applications, you may get security prompts. “Security” in this context refers to the so-called “object model guard” that triggers security prompts and blocks access to certain features in an effort to prevent malicious programs from harvesting email addresses from Outlook data and using Outlook to propagate viruses and spam. These prompts cannot simply be turned off, except in Outlook 2007 and above with an anti-virus application running.

To avoid security prompts or issues you can:

  • Create a COM add-in and use the "safe" application instance which doesn't trigger security prompts or issues.
  • Use a low-level code which doesn't trigger security prompts - Extended MAPI. Or just you may consider any wrapper around that API such as Redemption.
  • Use the Outlook Security Manager component for suppressing such prompts or issues caused by the OOM.
  • Set up a group policy to avoid prompts.
  • Set up any up-to-date antivirus software.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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